home *** CD-ROM | disk | FTP | other *** search
/ Beijing Paradise BBS Backup / PARADISE.ISO / software / BBSDOORW / PPL4C11.ZIP / ZMODEM.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-18  |  33.5 KB  |  1,636 lines

  1. /*
  2. **
  3. **   --- please read this ! ---
  4. **
  5. **  This source code is in "shrouded" form. It is distributed in this form
  6. **  rather than as a library (.LIB) file because of the inconsistancies
  7. **  between object files generated by different compilers. To support several
  8. **  compilers would require a .LIB file for each compiler manufacturer, and
  9. **  sometimes several versions of the .LIB file are needed for the different
  10. **  versions of the same manufacturers compiler!
  11. **
  12. **  You can compile this code, but you will have to register with us in order
  13. **  to get the normal (commented) C source code with normal variable names.
  14. */
  15.  
  16.  
  17. #include <stdio.h>
  18. #include <stdlib.h>
  19. #include <ctype.h>
  20. #include <fcntl.h>
  21. #include <string.h>
  22. #include <sys\types.h>
  23. #include <sys\stat.h>
  24. #include <malloc.h>
  25. #include <dos.h>
  26. #include <conio.h>
  27. #include <io.h>
  28.  
  29. #include "zmodem.h"
  30. #include "datetime.h"
  31. #include "term_io.h"
  32. #include "dir_io.h"
  33. #include "dos_io.h"
  34. #include "zdate.h"
  35. #include "crc16.h"
  36. #include "crc32.h"
  37. #include "pcl4c.h"
  38. #include "ascii.h"
  39. #include "zconst.h"
  40. #include "modem_io.h"
  41. #include "win_io.h"
  42. #include "term.h"
  43.  
  44. #define ABORT_CHAR   CAN
  45.  
  46. #define MAX_ERRORS   5
  47. #define ZDELAY       2
  48. #define CARRIER_TEST 0
  49.  
  50. #define LOW(x)  (0x00ff&(x))
  51. #define HIGH(x) (0x00ff&((x)>>8))
  52.  
  53. #define BYTE unsigned char
  54. #define WORD unsigned int
  55. #define BOOL int
  56.  
  57. #define STRING_SIZE 50
  58. #define FALSE 0
  59. #define TRUE !FALSE
  60.  
  61. #define ZATTNLEN    32
  62.  
  63. #define ZBUFSIZE  1024
  64.  
  65. #define V59     18
  66. #define V99    36
  67. #define V37     9
  68. #define V90    2
  69.  
  70.  
  71. static int  V15 = 1;
  72. static BOOL UseCrc32 = TRUE;
  73.  
  74.  
  75. static int  FatalError = 0;
  76. static int  V13;
  77. static int  V63;
  78. static long V71;
  79. static BYTE V70[4];
  80. static int  V72;
  81. static int  V73;
  82. static int  V69;
  83. static BYTE V3[ZATTNLEN];
  84. static char V28[15];
  85. static WORD V31;
  86. static WORD V27;
  87. static long V26;
  88. static long V102;
  89. static BYTE V101[4];
  90. static WORD V23;
  91. static int  V84;
  92. static char V41[16] = {"0123456789abcdef"};
  93. static char *AbortedMsg = "Aborted by USER";
  94.  
  95. static char *V53[21] =
  96.        {"ZRQINIT", "ZRINIT",  "ZSINIT",    "ZACK",
  97.         "ZFILE",   "ZSKIP",   "ZNAK",      "ZABORT",
  98.         "ZFIN",    "ZRPOS",   "ZDATA",     "ZEOF",
  99.         "ZFERR",   "ZCRC",    "ZCHALLENGE","ZCOMPL",
  100.         "ZCAN",    "ZFREECNT","ZCOMMAND",  "ZSTDERR",
  101.         "ZUNKNOWN"};
  102.  
  103. static char *V52[4] = {"ZBIN ", "ZHEX ", "ZBIN32 ", " "};
  104.  
  105.  
  106.  
  107. static int  V61;
  108. static BYTE V98;
  109. static int  V68;
  110. static long V30;
  111. static BOOL V45;
  112. static BOOL V21;
  113. static BYTE Zconv;
  114. static BYTE V65[ZBUFSIZE];
  115.  
  116.  
  117.  
  118. static int  V44;
  119. static long V82;
  120. static int  V66;
  121. static BYTE V100[ZBUFSIZE];
  122.  
  123.  
  124.  
  125. void V107(char V9, int V103, int V43, BYTE *V39)
  126. {int i;
  127.  char V87[STRING_SIZE];
  128.  char V88[12];
  129.  if(V103 > 20) V103 = 20;
  130.  *V87 = V9;
  131.  *(V87+1) = ':';
  132.  *(V87+2) = '\0';
  133.  if(V103<0) switch(V103)
  134.    {case -42:
  135.       strcat(V87, "MESSED_UP");
  136.       break;
  137.     case -41:
  138.       strcat(V87, "ZNOCARRIER");
  139.       break;
  140.     case -40:
  141.       strcat(V87, "ZERROR");
  142.       break;
  143.     case -1:
  144.       strcat(V87, "ZTIMEOUT");
  145.       break;
  146.    }
  147.  else
  148.    {if(V15)
  149.       {if( (V43>=ZBIN) && (V43<=ZBIN32)) strcat(V87,V52[V43-65]);
  150.        strcat(V87,V53[V103]);
  151.        strcat(V87," [");
  152.        for(i=0;i<=3;i++)
  153.          {sprintf(V88,"%d",V39[i]);
  154.           strcat(V87,V88);
  155.           if(i<3) strcat(V87,",");
  156.           else strcat(V87,"]");
  157.          }
  158.       }
  159.    }
  160.  if( *(V87+2) != '\0') WriteMsg(V87);
  161. }
  162.  
  163.  
  164.  
  165. void V122(BYTE V92)
  166. {static BYTE V47;
  167.  switch(0x7f & V92)
  168.    {case CR:
  169.       if((BYTE)(0x7f&V47)!=0x40)
  170.          {V47 = V92;
  171.           break;
  172.          }
  173.       
  174.     case ZDLE:
  175.     case DLE:
  176.     case XON:
  177.     case XOFF:
  178.       CharPut(V63,(char)ZDLE);
  179.       V47 = 0x40 ^ V92;
  180.       break;
  181.     default:
  182.       V47 = V92;
  183.       break;
  184.    }
  185.  CharPut(V63,(char)V47);
  186. }
  187.  
  188.  
  189.  
  190. unsigned long V106(int V38)
  191. {int  n;
  192.  BYTE V25[ZBUFSIZE];
  193.  unsigned long V12;
  194.  int  V6;
  195.  V12 = 0xFFFFFFFF;
  196.  lseek(V38,0,SEEK_SET);
  197.  do
  198.     {V6 = read(V38,V25,ZBUFSIZE);
  199.      for(n=0;n<V6;n++) V12 = UpdateCrc32(V25[n],V12);
  200.     } while (V6 == ZBUFSIZE);
  201.  lseek(V38,0,SEEK_SET);
  202.  return V12;
  203. }
  204.  
  205.  
  206.  
  207. BOOL V105(void)
  208. {
  209.  SioTxFlush(V63);
  210.  
  211.  if(!TestDSR(V63)) return FALSE;
  212. #if CARRIER_TEST
  213.  
  214.  return SioDCD(V63);
  215. #else
  216.  return TRUE;
  217. #endif
  218. }
  219.  
  220.  
  221.  
  222. int V110(int V96)
  223. {int r;
  224.  while(1)
  225.     {if(!V105()) return RCDO;
  226.      r = CharGet(V63,1);
  227.      if(r<-1)
  228.        {WriteIntMsg("ERROR",r);
  229.         return r;
  230.        }
  231.      if(r >= 0) return r;
  232.      if(--V96<=0) return ZTIMEOUT;
  233.     }
  234. }
  235.  
  236.  
  237.  
  238. int V115(void)
  239. {int c;
  240.  while(1)
  241.    {if((c = V110(V72)) < 0) return c;
  242.     c &= 0x7f;
  243.     if((c!=XON)&&(c!=XOFF)) return c;
  244.    }
  245. }
  246.  
  247.  
  248.  
  249. void V133(void)
  250. {int n;
  251.  SioTxClear(V63);
  252.  for(n=1;n<=8;n++)
  253.    {CharPut(V63,(char)(CAN));
  254.     SioDelay(V90);
  255.    }
  256.  for(n=1;n<=10;n++) CharPut(V63,(char)(BS));
  257. }
  258.  
  259.  
  260.  
  261. void V121(BYTE *p)
  262. {int i = 0;
  263.  while ((i < ZBUFSIZE) && (p[i] != 0))
  264.    {switch( p[i] )
  265.       {case 221:
  266.          SioBrkSig(V63,'A');
  267.          break;
  268.        case 222:
  269.          SioDelay(V99);
  270.          break;
  271.        default:
  272.          CharPut(V63,(char)(p[i]));
  273.          break;
  274.       }
  275.     i++;
  276.    }
  277. }
  278.  
  279.  
  280.  
  281. void V119(BYTE Byte)
  282. {
  283.  CharPut(V63,V41[0x000f & (Byte >> 4)]);
  284.  CharPut(V63,V41[0x000f & Byte]);
  285. }
  286.  
  287.  
  288.  
  289. void V139(int V42, BYTE *V40)
  290. {int   i;
  291.  WORD  V12;
  292.  V107('S',V42,ZHEX,V40);
  293.  CharPut(V63,(char)(ZPAD));
  294.  CharPut(V63,(char)(ZPAD));
  295.  CharPut(V63,(char)(ZDLE));
  296.  CharPut(V63,(char)(ZHEX));
  297.  V119((BYTE)V42);
  298.  V12 = UpdateCrc16((BYTE)V42,0);
  299.  for(i=0;i<4;i++)
  300.     {V119(V40[i]);
  301.      V12 = UpdateCrc16(V40[i],V12);
  302.     }
  303.  V12 = UpdateCrc16(0,V12);
  304.  V12 = UpdateCrc16(0,V12);
  305.  V119((BYTE)HIGH(V12));
  306.  V119((BYTE)LOW(V12));
  307.  CharPut(V63,(char)(CR));
  308.  CharPut(V63,(char)(LF));
  309.  if((V42 != ZFIN) && (V42 != ZACK))
  310.       CharPut(V63,(char)XON);
  311.  if(!V105())
  312.       SioTxClear(V63);
  313. }
  314.  
  315.  
  316.  
  317. long V114(BYTE *V40)
  318. {long  V49;
  319.  V49 = V40[ZP3];
  320.  V49 = (V49 << 8) | V40[ZP2];
  321.  V49 = (V49 << 8) | V40[ZP1];
  322.  V49 = (V49 << 8) | V40[ZP0];
  323.  return V49;
  324. }
  325.  
  326.  
  327.  
  328. void V120(long V49)
  329. {
  330.  V101[ZP0] = (BYTE)(V49);
  331.  V101[ZP1] = (BYTE)(V49 >> 8);
  332.  V101[ZP2] = (BYTE)(V49 >> 16);
  333.  V101[ZP3] = (BYTE)(V49 >> 24);
  334. }
  335.  
  336.  
  337.  
  338. int V117(void)
  339. {int  c;
  340.  
  341. getzdl100:
  342.  if(!V105()) return RCDO;
  343.  if((c = V110(V72)) < 0) return c;
  344.  switch(c)
  345.    {case ZDLE:
  346.       break;
  347.     case XON:
  348.     case XOFF:
  349.       goto getzdl100;
  350.     default:
  351.       return c;
  352.    }
  353.  
  354. getzdl200:
  355.  if(!V105()) return RCDO;
  356.  
  357.  if((c = V110(V72)) < 0) return c;
  358.  if(c == CAN)
  359.     {
  360.      if((c = V110(V72)) < 0) return c;
  361.      if(c == CAN)
  362.         {
  363.          if((c = V110(V72)) < 0) return c;
  364.          if(c == CAN)
  365.             {
  366.              if((c = V110(V72)) < 0) return c;
  367.             }
  368.         }
  369.     }
  370.  
  371.  switch( c )
  372.     {case CAN:
  373.         
  374.         return GOTCAN;
  375.      case ZCRCE:
  376.      case ZCRCG:
  377.      case ZCRCQ:
  378.      case ZCRCW:
  379.         
  380.         return (c | GOTOR);
  381.      case ZRUB0:
  382.         
  383.         return 0x007f;
  384.      case ZRUB1:
  385.         
  386.         return 0x00ff;
  387.      case XON:
  388.      case XOFF:
  389.         goto getzdl200;
  390.      default:
  391.         if((0x60 & c) == 0x40) return (0x40 ^ c);
  392.         break;
  393.     }
  394.  WriteHexMsg("Bad escape sequence ",c);
  395.  return ZERROR;
  396. }
  397.  
  398.  
  399.  
  400. int V112(void)
  401. {int c, n;
  402.  n = V115();
  403.  if(n < 0) return n;
  404.  n = n - 0x30;
  405.  if(n > 9)  n = n - 39;
  406.  if((0xfff0 & n) != 0) return ZERROR;
  407.  c = V115();
  408.  if(c < 0) return c;
  409.  c = c - 0x30;
  410.  if (c > 9)  c = c - 39;
  411.  if((0xfff0 & c) != 0) return ZERROR;
  412.  return ( (n << 4) | c );
  413. }
  414.  
  415.  
  416.  
  417. int V113(BYTE *V40)
  418. {WORD V12;
  419.  int c, n;
  420.  c = V112();
  421.  if(c < 0) return c;
  422.  V73 = c;
  423.  V12 = UpdateCrc16((BYTE)V73,0);
  424.  for(n=0;n<4;n++)
  425.     {c = V112();
  426.      if(c < 0) return c;
  427.      V40[n] = LOW(c);
  428.      V12 = UpdateCrc16((BYTE)LOW(c),V12);
  429.     }
  430.  c = V112();
  431.  if (c < 0) return c;
  432.  V12 = UpdateCrc16((BYTE)LOW(c), V12);
  433.  c = V112();
  434.  if(c < 0) return c;
  435.  V12 = UpdateCrc16((BYTE)LOW(c), V12);
  436.  if(V12 != 0)
  437.     {V23++;
  438.      WriteIntMsg("Error(1)=",V23);
  439.      return ZERROR;
  440.     }
  441.  if(V110(1) == CR)  c = V110(1);
  442.  return V73;
  443. }
  444.  
  445.  
  446.  
  447. int V108(BYTE *V40)
  448. {WORD V12;
  449.  int  c, n;
  450.  c = V117();
  451.  if(c < 0) return c;
  452.  V73 = c;
  453.  V12 = UpdateCrc16((BYTE)V73,0);
  454.  
  455.  for(n=0;n<4;n++)
  456.     {c = V117();
  457.      if(HIGH(c) != 0) return c;
  458.      V40[n] = LOW(c);
  459.      V12 = UpdateCrc16((BYTE)LOW(c),V12);
  460.     }
  461.  
  462.  c = V117();
  463.  if ((BYTE)HIGH(c) != 0) return c;
  464.  V12 = UpdateCrc16((BYTE)LOW(c),V12);
  465.  c = V117();
  466.  if((BYTE)HIGH(c) != 0) return c;
  467.  V12 = UpdateCrc16((BYTE)LOW(c),V12);
  468.  
  469.  if(V12 != 0)
  470.     {V23++;
  471.      WriteIntMsg("Error(2)=",V23);
  472.      return 0;
  473.     }
  474.  return V73;
  475. }
  476.  
  477.  
  478.  
  479. int V109(BYTE *V40)
  480. {unsigned long V12;
  481.  int  c, n;
  482.  c = V117();
  483.  if (c < 0) return c;
  484.  V73 = c;
  485.  V12 = UpdateCrc32((BYTE)V73,0xffffffffL);
  486.  
  487.  for(n=0;n<4;n++)
  488.     {c = V117();
  489.      if((BYTE)HIGH(c) != 0) return c;
  490.      V40[n] = (BYTE)LOW(c);
  491.      V12 = UpdateCrc32((BYTE)LOW(c),V12);
  492.     }
  493.  
  494.  for(n=0;n<4;n++)
  495.     {c = V117();
  496.      if((BYTE)HIGH(c) != 0) return c;
  497.      V12 = UpdateCrc32((BYTE)LOW(c),V12);
  498.     }
  499.  
  500.  if (V12 != 0xdebb20e3)
  501.     {V23++;
  502.      WriteIntMsg("Error(3)=",V23);
  503.      return ZERROR;
  504.     }
  505.  return V73;
  506. }
  507.  
  508.  
  509.  
  510. int V111(BYTE *V40)
  511. {int i;
  512.  int c, n;
  513.  int CANcount;
  514.  n = 32;
  515.  CANcount = 5;
  516. V1:
  517.  if(kbhit()) if(getch() == ABORT_CHAR)
  518.       {V133();
  519.        WriteMsg("Cancelled by USER");
  520.        return ZCAN;
  521.       }
  522.  V69 = 0;
  523.  V73 = 0;
  524.  
  525.  c = V115();
  526.  switch( c )
  527.     {case ZPAD:
  528.         break;
  529.      case RCDO:
  530.      case ZTIMEOUT:
  531.         goto V18;
  532.      case CAN:
  533. V36:
  534.         if(--CANcount < 0)
  535.            {c = ZCAN;
  536.             goto V18;
  537.            }
  538.         c = V110(1);
  539.         switch( c )
  540.            {case ZTIMEOUT:
  541.                goto V1;
  542.             case ZCRCW:
  543.                c = ZERROR;
  544.                goto V18;
  545.             case RCDO:
  546.                goto V18;
  547.             case CAN:
  548.                CANcount--;
  549.                if(CANcount < 0)
  550.                   {c = ZCAN;
  551.                    goto V18;
  552.                   }
  553.                goto V1;
  554.             default:
  555.                
  556.                break;
  557.            } 
  558.         break;
  559.      default: 
  560.         
  561. again2:
  562.         if(--n < 0)
  563.             {V23++;
  564.              WriteIntMsg("Header is unrecognizable. Errors=",V23);
  565.              return ZERROR;
  566.             }
  567.         if(c != CAN)  CANcount = 5;
  568.         
  569.         goto V1;
  570.     } 
  571.     
  572.     CANcount = 5;
  573. V81:
  574.    c = V115();
  575.    switch( c )
  576.      {case ZDLE:
  577.          break;
  578.       case ZPAD:
  579.          
  580.          goto V81;
  581.       case RCDO:
  582.       case ZTIMEOUT:
  583.          goto V18;
  584.       default:
  585.          goto again2;
  586.      } 
  587.    
  588.    c = V115();
  589.    switch( c )
  590.       {case ZBIN32:
  591.           V69 = ZBIN32;
  592.           c = V109(V40);
  593.           break;
  594.        case ZBIN:
  595.           V69 = ZBIN;
  596.           c = V108(V40);
  597.           break;
  598.        case ZHEX:
  599.           V69 = ZHEX;
  600.           c = V113(V40);
  601.           break;
  602.        case CAN:
  603.           goto V36;
  604.        case RCDO:
  605.        case ZTIMEOUT:
  606.           goto V18;
  607.        default:
  608.           goto again2;
  609.    } 
  610.    V71 = V114(V40);
  611. V18:
  612.    V107('R',c,V69,V40);
  613.    return c;
  614. }
  615.  
  616.  
  617.  
  618. int V124(BYTE *V7,int V4)
  619. {
  620.  int  c, d;
  621.  int  n, i;
  622.  unsigned long V12;
  623.  BOOL V18;
  624.  int  RetValue = ZERROR;
  625.  V68 = 0;
  626.  V18 = FALSE;
  627.  V12 = 0xffffffffL;
  628.  do
  629.     {c = V117();
  630.      if((BYTE)HIGH(c) != 0)
  631.         {
  632. V14:
  633.           switch( c )
  634.               {case GOTCRCE:
  635.                case GOTCRCG:
  636.                case GOTCRCQ:
  637.                case GOTCRCW:
  638.                   d = c;
  639.                   V12 = UpdateCrc32((BYTE)LOW(c),V12);
  640.                   
  641.                   for(n=0;n<4;n++)
  642.                      {c = V117();
  643.                       if((BYTE)HIGH(c) != 0)  goto V14;
  644.                       V12 = UpdateCrc32((BYTE)LOW(c),V12);
  645.                      }
  646.                   
  647.                   if(V12 != 0xdebb20e3)
  648.                      {V23++;
  649.                       WriteIntMsg("Error(4)=",V23);
  650.                       RetValue = ZERROR;
  651.                      }
  652.                   else RetValue = d;
  653.                   V18 = TRUE;
  654.                   break;
  655.                case GOTCAN:
  656.                   RetValue = ZCAN;
  657.                   V18 = TRUE;
  658.                   break;
  659.                case ZTIMEOUT:
  660.                   RetValue = c;
  661.                   V18 = TRUE;
  662.                   break;
  663.                case RCDO:
  664.                   RetValue = c;
  665.                   V18 = TRUE;
  666.                   break;
  667.                default:
  668.                   WriteIntMsg("Garbage(1) = ",c);
  669.                   SioDelay(V37);
  670.                   SioRxClear(V63);
  671.                   RetValue = c;
  672.                   V18 = TRUE;
  673.               } 
  674.         }
  675.       if(!V18)
  676.          {if(--V4 < 0)
  677.              {WriteHexMsg("Long packet(32). Byte=",c);
  678.               RetValue = ZERROR;
  679.               V18 = TRUE;
  680.              }
  681.           
  682.           V7[(int)V68] = (BYTE)LOW(c);
  683.           V68++;
  684.           V12 = UpdateCrc32((BYTE)LOW(c),V12);
  685.          }
  686.     } while (!V18);
  687.   return RetValue;
  688. }
  689.  
  690.  
  691.  
  692. int V127(BYTE *V7, int V4)
  693. {int  i;
  694.  int  c, d;
  695.  WORD V12;
  696.  BOOL V18;
  697.  int RetValue = ZERROR;
  698.  if(V69 == ZBIN32)
  699.      {
  700.       return V124(V7,V4);
  701.      }
  702.  V12 = 0;
  703.  V68 = 0;
  704.  V18 = FALSE;
  705.  do
  706.     {c = V117();
  707.      if((BYTE)HIGH(c) != 0)
  708.         {
  709. V14:
  710.          switch( c )
  711.             {case GOTCRCE:
  712.              case GOTCRCG:
  713.              case GOTCRCQ:
  714.              case GOTCRCW:
  715.                 d = c;
  716.                 V12 = UpdateCrc16((BYTE)LOW(c),V12);
  717.                 
  718.                 c = V117();
  719.                 if((BYTE)HIGH(c) != 0)  goto V14;
  720.                 V12 = UpdateCrc16((BYTE)LOW(c),V12);
  721.                 c = V117();
  722.                 if ((BYTE)HIGH(c) != 0)  goto V14;
  723.                 V12 = UpdateCrc16((BYTE)LOW(c),V12);
  724.                 
  725.                 if(V12 != 0)
  726.                     {V23++;
  727.                      WriteIntMsg("Error(5)=",V23);
  728.                      RetValue = ZERROR;
  729.                      V18 = TRUE;
  730.                     }
  731.                 RetValue = d;
  732.                 V18 = TRUE;
  733.                 break;
  734.              case GOTCAN:
  735.                 WriteMsg("Received CAN");
  736.                 RetValue = ZCAN;
  737.                 V18 = TRUE;
  738.                 break;
  739.              case ZTIMEOUT:
  740.                 RetValue = c;
  741.                 V18 = TRUE;
  742.                 break;
  743.              case RCDO:
  744.                 WriteMsg("Lost carrier:1");
  745.                 RetValue = c;
  746.                 V18 = TRUE;
  747.                 break;
  748.              default:
  749.                 WriteHexMsg("Garbage(2) = ",c);
  750.                 SioDelay(V37);
  751.                 SioRxClear(V63);
  752.                 RetValue = c;
  753.                 V18 = TRUE;
  754.                 break;
  755.             } 
  756.         } 
  757.      if(!V18)
  758.         {if(--V4 < 0)
  759.             {WriteHexMsg("Long packet(16). Byte=",c);
  760.              RetValue = ZERROR;
  761.              V18 = TRUE;
  762.             }
  763.          V7[(int)V68] = (BYTE)LOW(c);
  764.          V68++;
  765.          V12 = UpdateCrc16((BYTE)LOW(c),V12);
  766.         }
  767.     } while (!V18);
  768.  return RetValue;
  769. }
  770.  
  771.  
  772.  
  773. void V74(void)
  774. {int  n, i;
  775.  V120(V71);
  776.  n = 4;
  777.  SioDelay(ZDELAY);
  778.  SioRxClear(V63);
  779.  do
  780.     {V139(ZFIN,V101);
  781.      switch( V110(V99) )
  782.         {case ZTIMEOUT:
  783.          case RCDO:
  784.             return;
  785.          case 79:
  786.             if(V110(V59) == 79) ; 
  787.             SioDelay(V37);
  788.             SioRxClear(V63);
  789.             return;
  790.          default:
  791.             SioDelay(V37);
  792.             SioRxClear(V63);
  793.             n--;
  794.         } 
  795.     } while (n > 0);
  796. }
  797.  
  798.  
  799.  
  800. int V76(void)
  801. {int  c, n, V24;
  802.  BYTE Flags;
  803.  for(n=0;n<ZATTNLEN;n++) V3[n] = 0;
  804.  V23 = 0;
  805.  V24 = 0;
  806.  for(n=10;n>=0;n--)
  807.     {if(!V105())
  808.         {WriteMsg("Lost carrier:2");
  809.          return ZERROR;
  810.         }
  811.       V120(0L);
  812.       if(V13)
  813.          {Flags = CANFDX | CANOVIO | CANFC32 | CANBRK;
  814.           WriteMsg("Set CRC 32");
  815.          }
  816.       else
  817.          {Flags = CANFDX | CANOVIO | CANBRK;
  818.           WriteMsg("Set CRC 16");
  819.          }
  820.       V101[ZF0] = Flags;
  821.       V139(V98,V101);
  822.       if(V98 == ZSKIP)  V98 = ZRINIT;
  823. V1:
  824.       c = V111(V70);
  825.       switch( c )
  826.          {case ZFILE:
  827.              Zconv = V70[ZF0];
  828.              V98 = ZRINIT;
  829.              c = V127(V65,ZBUFSIZE);
  830.              if(c == GOTCRCW) return ZFILE;
  831.              V139(ZNAK,V101);
  832.              goto V1;
  833.           case ZSINIT:
  834.              c = V127(V3,ZATTNLEN);
  835.              if(c == GOTCRCW) V139(ZACK,V101);
  836.              else V139(ZNAK,V101);
  837.              goto V1;
  838.           case ZFREECNT:
  839.              
  840.              V120(FreeDiskSpace());
  841.              V139(ZACK,V101);
  842.              goto V1;
  843.           case ZCOMMAND:
  844.              c = V127(V65,ZBUFSIZE);
  845.              if(c == GOTCRCW)
  846.                 {V120(0);
  847.                  do
  848.                     {V139(ZCOMPL,V101);
  849.                      V24++;
  850.                     } while ((V24 <= MAX_ERRORS) && (V111(V70) != ZFIN));
  851.                  V74();
  852.                  return ZCOMPL;
  853.                 }
  854.              V139(ZNAK,V101);
  855.              goto V1;
  856.           case ZCOMPL:
  857.           case ZFIN:
  858.              return ZCOMPL;
  859.           case ZCAN:
  860.           case RCDO:
  861.              return c;
  862.          } 
  863.     } 
  864.  WriteMsg("Timed out");
  865.  return ZERROR;
  866. }
  867.  
  868.  
  869.  
  870. int V75(void)
  871. {int  i, p;
  872.  char c;
  873.  char V94[STRING_SIZE];
  874.  long V93;
  875.  char V87[STRING_SIZE];
  876.  V45 = TRUE;
  877.  V26 = 0L;
  878.  V94[0] = '\0';
  879.  
  880.  p = 0;
  881.  while(1)
  882.    {if(p==ZBUFSIZE) break;
  883.     c = toupper((char)V65[p]);
  884.     if(c=='\0') break;
  885.     else V94[p++] = c;
  886.    }
  887.  V94[p++] = '\0';
  888.  
  889.  
  890.  strcpy(V28,V94);
  891.  
  892.  
  893.  V26 = 0L;
  894.  while(1)
  895.    {if(p==ZBUFSIZE) break;
  896.     c = (char)V65[p];
  897.     if((c==' ')||(c=='\0')) break;
  898.     V26 = (10 * V26) + (c - 0x30);
  899.     p++;
  900.    }
  901.  p++;
  902.  
  903.  i = 0;
  904.  while(1)
  905.    {if(p==ZBUFSIZE) break;
  906.     c = V65[p++];
  907.     if((c<'0')||(c>'7')) break;
  908.     V94[i++] = c;
  909.    }
  910.  V94[i] = '\0';
  911.  p++;
  912.  Z2DosDate(V94,&V27,&V31);
  913.  
  914.  if(FindFirst(V28,NULL,&V93))
  915.     {
  916.      if(V93 > 0)
  917.        {if((Zconv == ZCRESUM) && (V26 > V93))
  918.            {V30 = V93;
  919.             V61 = open(V28,O_WRONLY|O_APPEND|O_BINARY,S_IWRITE);
  920.             if(V61<0)
  921.                {sprintf(V87,"Unable to open(1) %s",V28);
  922.                 WriteMsg(V87);
  923.                 return ZERROR;
  924.                }
  925.             WriteLongMsg("Recovering to",V30);
  926.            }
  927.         else
  928.            {sprintf(V87,"%s is already complete",V28);
  929.             WriteMsg(V87);
  930.             return ZSKIP;
  931.            }
  932.        }
  933.     }
  934.  else
  935.     {
  936.      V30 = 0;
  937.      V61 = open(V28,O_CREAT|O_TRUNC|O_WRONLY|O_BINARY,S_IWRITE);
  938.      if(V61<0)
  939.         {strcpy(V87,"Unable to create ");
  940.          strcat(V87,V28);
  941.          WriteMsg(V87);
  942.          return ZERROR;
  943.         }
  944.     }
  945.  WriteLongMsg("Size=",V26);
  946.  return ZOK;
  947. }
  948.  
  949.  
  950.  
  951. int V77(long *V67)
  952. {int RetValue;
  953.  if(kbhit()) if(getch() == ABORT_CHAR)
  954.      {WriteMsg(AbortedMsg);
  955.       V133();
  956.       return ZERROR;
  957.      }
  958.  if(write(V61,V65,V68)!=V68)
  959.      {WriteIntMsg("Disk write error",errno);
  960.       RetValue = ZERROR;
  961.      }
  962.   else RetValue = ZOK;
  963.   *V67 = *V67 + V68;
  964.   return RetValue;
  965. }
  966.  
  967.  
  968. int V128(void)
  969. {int  c, n;
  970.  long V67;
  971.  BOOL V18;
  972.  V23 = 0;
  973.  V18 = FALSE;
  974.  V21 = FALSE;
  975.  c = V75();
  976.  if(c != ZOK)
  977.     {if(c == ZSKIP)  V98 = ZSKIP;
  978.      return c;
  979.     }
  980.  c = ZOK;
  981.  n = MAX_ERRORS;
  982.  V67 = V30;
  983.  V71 = V30;
  984.  do
  985.     {V120(V67);
  986.      V139(ZRPOS,V101);
  987. V58:
  988.      c = V111(V70);
  989.      switch( c )
  990.         {case ZDATA:
  991.             if(V71 != V67)
  992.                 {n--;
  993.                  V23++;
  994.                  WriteIntMsg("Error(6)=",V23);
  995.                  if(n < 0)  goto V22;
  996.                  WriteMsg("Bad position");
  997.                  V121(V3);
  998.                 }
  999.             else
  1000.                 {
  1001. V51:
  1002.                  c = V127(V65,ZBUFSIZE);
  1003.                  switch( c )
  1004.                      {case ZCAN:
  1005.                       case RCDO:
  1006.                           goto V22;
  1007.                       case ZERROR:
  1008.                           n--;
  1009.                           V23++;
  1010.                           WriteIntMsg("Error",V23);
  1011.                           if(n < 0)  goto V22;
  1012.                           V121(V3);
  1013.                           break;
  1014.                       case ZTIMEOUT:
  1015.                           n--;
  1016.                           if(n < 0)  goto V22;
  1017.                           break;
  1018.                       case GOTCRCW:
  1019.                           n = MAX_ERRORS;
  1020.                           c = V77(&V67);
  1021.                           if(c != ZOK) return c;
  1022.                           WriteLongMsg("ZCRCW: Pos=",V67);
  1023.                           V120(V67);
  1024.                           V139(ZACK,V101);
  1025.                           goto V58;
  1026.                       case GOTCRCQ:
  1027.                           n = MAX_ERRORS;
  1028.                           c = V77(&V67);
  1029.                           if(c != ZOK) return c;
  1030.                           WriteLongMsg("ZCRCQ: Pos=",V67);
  1031.                           V120(V67);
  1032.                           V139(ZACK,V101);
  1033.                           goto V51;
  1034.                       case GOTCRCG:
  1035.                           n = MAX_ERRORS;
  1036.                           c = V77(&V67);
  1037.                           if (c != ZOK) return c;
  1038.                           WriteLongMsg("ZCRCG: Pos=",V67);
  1039.                           goto V51;
  1040.                       case GOTCRCE:
  1041.                           n = MAX_ERRORS;
  1042.                           c = V77(&V67);
  1043.                           if(c != ZOK) return c;
  1044.                           WriteLongMsg("ZCRCE: Pos=",V67);
  1045.                           goto V58;
  1046.                      } 
  1047.                 } 
  1048.             break;
  1049.          case ZNAK:
  1050.          case ZTIMEOUT:
  1051.             if (--n < 0)  goto V22;
  1052.             WriteLongMsg("ZNAK: Pos=",V67);
  1053.             break;
  1054.          case ZFILE:
  1055.             c = V127(V65,ZBUFSIZE);
  1056.             break;
  1057.          case ZEOF:
  1058.             if(V71 == V67) return c;
  1059.             else goto V58;
  1060.          case ZERROR:
  1061.             if(--n < 0)  goto V22;
  1062.             WriteLongMsg("ZERROR: Pos=",V67);
  1063.             V121(V3);
  1064.             break;
  1065.          default:
  1066.             return ZERROR;
  1067.       } 
  1068.    } while (!V18);
  1069. V22:
  1070.    return ZERROR;
  1071. }
  1072.  
  1073.  
  1074.  
  1075. int V126(void)
  1076. {int  c;
  1077.  long V96;
  1078.  char V87[50];
  1079.  while(TRUE)
  1080.      {if(!V105()) return ZERROR;
  1081.       V96 = SioTimer();
  1082.       c = V128();
  1083.       SetFileDT(V61,V27,V31);
  1084.       WriteCPS(V96,V26,V28,(c==ZSKIP));
  1085.       close(V61);
  1086.       switch( c )
  1087.          {case ZEOF:
  1088.           case ZSKIP:
  1089.              c = V76();
  1090.              switch( c )
  1091.                 {case ZFILE:
  1092.                     break;
  1093.                  case ZCOMPL:
  1094.                     V74();
  1095.                     return ZOK;
  1096.                  default:
  1097.                     return ZERROR;
  1098.                 } 
  1099.              break;
  1100.           default: 
  1101.              return c;
  1102.          } 
  1103.      } 
  1104. }
  1105.  
  1106.  
  1107.  
  1108. BOOL V125(int V62)
  1109. {int i;
  1110.  V63 = V62;
  1111.  V13 = UseCrc32;
  1112.  WriteIntMsg("zmReceive: V63 = COM",1+V63);
  1113.  V72 = 10 * V59;
  1114.  V98 = ZRINIT;
  1115.  i = V76();
  1116.  if((i==ZCOMPL) || ((i==ZFILE) && (V126() == ZOK)))
  1117.     {WriteMsg("Done.");
  1118.      return TRUE;
  1119.     }
  1120.  else
  1121.     {SioTxClear(V63);
  1122.      WriteMsg("Sending CAN");
  1123.      V133();
  1124.      WriteMsg("Done.");
  1125.      return FALSE;
  1126.     }
  1127. }
  1128.  
  1129.  
  1130.  
  1131. void V130(BYTE V42,BYTE *V40)
  1132. {unsigned long V12;
  1133.  int   i, n;
  1134.  V107('S',V42,ZBIN32,V40);
  1135.  CharPut(V63,(char)(ZPAD));
  1136.  CharPut(V63,(char)(ZDLE));
  1137.  CharPut(V63,(char)(ZBIN32));
  1138.  V122(V42);
  1139.  V12 = UpdateCrc32(V42,0xffffffffL);
  1140.  
  1141.  for(n=0;n<4;n++)
  1142.     {V122(V40[n]);
  1143.      V12 = UpdateCrc32(V40[n],V12);
  1144.     }
  1145.  V12 = ~V12;
  1146.  
  1147.  for(n=0;n<4;n++)
  1148.     {V122((BYTE)V12);
  1149.      V12 = (V12 >> 8);
  1150.     }
  1151.  if(V42 != ZDATA)  SioDelay(V90+ZDELAY);
  1152. }
  1153.  
  1154.  
  1155.  
  1156. void V131(BYTE V42,BYTE *V40)
  1157. {WORD V12;
  1158.  int  i, n;
  1159.  if(V13)
  1160.     {V130(V42,V40);
  1161.      return;
  1162.     }
  1163.  V107('S',V42,ZBIN,V40);
  1164.  CharPut(V63,(char)(ZPAD));
  1165.  CharPut(V63,(char)(ZDLE));
  1166.  CharPut(V63,(char)(ZBIN));
  1167.  V122(V42);
  1168.  V12 = UpdateCrc16(V42,0);
  1169.  for(n=0;n<4;n++)
  1170.     {V122(V40[n]);
  1171.      V12 = UpdateCrc16(V40[n],V12);
  1172.     }
  1173.  V12 = UpdateCrc16(0,V12);
  1174.  V12 = UpdateCrc16(0,V12);
  1175.  V122((BYTE)HIGH(V12));
  1176.  V122((BYTE)LOW(V12));
  1177.  if (V42 != ZDATA)  SioDelay(V90+ZDELAY);
  1178. }
  1179.  
  1180.  
  1181.  
  1182. void V134(BYTE *V7,int  V4,BYTE V33)
  1183. {unsigned long V12;
  1184.  int  i;
  1185.  
  1186.  V12 = 0xffffffffL;
  1187.  for(i=0;i<V4;i++)
  1188.     {V122(V7[i]);
  1189.      V12 = UpdateCrc32(V7[i],V12);
  1190.     }
  1191.  
  1192.  V12 = UpdateCrc32(V33,V12);
  1193.  V12 = (~V12);
  1194.  CharPut(V63,(char)(ZDLE));
  1195.  CharPut(V63,(char)(V33));
  1196.  
  1197.  for(i=0;i<4;i++)
  1198.     {V122((BYTE)V12);
  1199.      V12 = (V12 >> 8);
  1200.     }
  1201.  
  1202.  if(V33 == ZCRCW) CharPut(V63,(char)(XON));
  1203.  SioDelay(1+ZDELAY);
  1204. }
  1205.  
  1206.  
  1207.  
  1208. void V135(BYTE *V7,int V4,BYTE V33)
  1209. {WORD V12;
  1210.  int  i;
  1211.  if(V13)
  1212.     {V134(V7,V4,V33);
  1213.      return;
  1214.     }
  1215.  
  1216.  V12 = 0;
  1217.  for(i=0;i<V4;i++)
  1218.     {V122(V7[i]);
  1219.      V12 = UpdateCrc16(V7[i],V12);
  1220.     }
  1221.  
  1222.  V12 = UpdateCrc16(V33,V12);
  1223.  CharPut(V63,(char)(ZDLE));
  1224.  CharPut(V63,(char)(V33));
  1225.  V12 = UpdateCrc16(0,V12);
  1226.  V12 = UpdateCrc16(0,V12);
  1227.  
  1228.  V122((BYTE)HIGH(V12));
  1229.  V122((BYTE)LOW(V12));
  1230.  
  1231.  if(V33 == ZCRCW) CharPut(V63,(char)(XON));
  1232.  SioDelay(1+ZDELAY);
  1233. }
  1234.  
  1235.  
  1236.  
  1237. void V136(void)
  1238. {int  i;
  1239.  do
  1240.     {V120(V102);
  1241.      V139(ZFIN,V101);
  1242.      switch( V111(V70) )
  1243.         {case ZFIN:
  1244.             CharPut(V63,'O');
  1245.             CharPut(V63,'O');
  1246.             SioDelay(V90);
  1247.             SioTxClear(V63);
  1248.             return;
  1249.          case ZCAN:
  1250.          case RCDO:
  1251.          case ZFERR:
  1252.          case ZTIMEOUT:
  1253.             return;
  1254.         }
  1255.     } while (TRUE);
  1256. }
  1257.  
  1258.  
  1259.  
  1260. int V85(void)
  1261. {int  n, c;
  1262.  WriteMsg("Getting receiver info.");
  1263.  for(n=1;n<MAX_ERRORS;n++)
  1264.     {c = V111(V70);
  1265.      switch( c )
  1266.         {case ZCHALLENGE:
  1267.             V120(V71);
  1268.             V139(ZACK,V101);
  1269.             break;
  1270.          case ZCOMMAND:
  1271.             V120(0L);
  1272.             V139(ZRQINIT,V101);
  1273.             break;
  1274.          case ZRINIT:
  1275.             V66 = ((WORD)(V70[ZP1]) << 8) | V70[ZP0];
  1276.             V13 = (V70[ZF0] & CANFC32);
  1277.             if(V13) WriteMsg("Get CRC 32");
  1278.             else WriteMsg("Get CRC 16");
  1279.             return ZOK;
  1280.          case ZCAN:
  1281.          case RCDO:
  1282.          case ZTIMEOUT:
  1283.             return ZERROR;
  1284.          default:
  1285.             if((c != ZRQINIT)||(V70[ZF0] != ZCOMMAND))
  1286.               V139(ZNAK,V101);
  1287.             break;
  1288.         } 
  1289.     } 
  1290.  return ZERROR;
  1291. }
  1292.  
  1293.  
  1294.  
  1295. int V86(void)
  1296. {int  i, c;
  1297.  int  V55 = MAX_ERRORS;
  1298.  do
  1299.     {c = V111(V70);
  1300.      
  1301.      SioRxClear(V63);
  1302.      switch( c )
  1303.         {case ZTIMEOUT:
  1304.             if(--V55 < 0) return ZERROR;
  1305.          case ZCAN:
  1306.          case ZABORT:
  1307.          case ZFIN:
  1308.          case RCDO:
  1309.             return ZERROR;
  1310.          case ZRPOS:
  1311.             if(lseek(V44,V71,SEEK_SET)<0)
  1312.                {WriteMsg("File seek error");
  1313.                 return ZERROR;
  1314.                }
  1315.             WriteLongMsg("New Pos=",V71);
  1316.             V102 = V71;
  1317.             return c;
  1318.          case ZSKIP:
  1319.          case ZRINIT:
  1320.          case ZACK:
  1321.             return c;
  1322.          default:
  1323.             WriteMsg("Unspecified error!");
  1324.             V131(ZNAK,V101);
  1325.             break;
  1326.         } 
  1327.     } while (TRUE);
  1328. }
  1329.  
  1330.  
  1331.  
  1332. int V138(void)
  1333. {int i, c;
  1334.  int V33;
  1335.  int V56;
  1336.  int V5;
  1337.  int V8;
  1338.  int V50;
  1339.  int V34;
  1340.  int V35;
  1341.  V35 = 1;
  1342.  V50 = ZBUFSIZE;
  1343.  V5 = V50;
  1344. V80:
  1345.  
  1346.  if(SioRxQue(V63) == 0)
  1347.     {
  1348. V104:
  1349.      c = V86();
  1350.      switch( c )
  1351.         {case ZSKIP:
  1352.             return ZSKIP;
  1353.          case ZACK:
  1354.             break;
  1355.          case ZRPOS:
  1356.             V23++;
  1357.             WriteIntMsg("Error(7)=",V23);
  1358.             
  1359.             if ((V5 >> 2) > 32) V5 = (V5 >> 2);
  1360.             else V5 = 32;
  1361.             V34 = 0;
  1362.             V35 = (V35 << 1) | 1;
  1363.             break;
  1364.          case ZRINIT:
  1365.             return ZOK;
  1366.          default:
  1367.             return ZERROR;
  1368.       } 
  1369.       
  1370.       while (SioRxQue(V63) > 0)
  1371.          {i = V110(ZDELAY);
  1372.           if(i<-1) break;
  1373.           switch( i )
  1374.               {case CAN:
  1375.                case ZPAD:
  1376.                   goto V104;
  1377.                case RCDO:
  1378.                   return ZERROR;
  1379.               } 
  1380.          }
  1381.     }
  1382.    
  1383.    V56 = V66;
  1384.    V120(V102);
  1385.    V131(ZDATA,V101);
  1386.    do
  1387.       {if(kbhit()) if(getch() == ABORT_CHAR)
  1388.           {WriteMsg(AbortedMsg);
  1389.            V133();
  1390.            goto V60;
  1391.           }
  1392.        if(!V105())  goto V60;
  1393.        V8 = read(V44,V100,V5);
  1394.        if(V8<0)
  1395.           {WriteMsg("Error reading disk");
  1396.            V133();
  1397.            goto V60;
  1398.           }
  1399.        if(V8 < V5) V33 = ZCRCE;
  1400.        else
  1401.           {if((V66 != 0) && ((V56 - V8) <= 0))
  1402.              {V56 = (V56 - V8);
  1403.               V33 = ZCRCW;
  1404.              }
  1405.            else
  1406.              {if(V84) V33 = ZCRCG;
  1407.               else V33 = ZCRCW;
  1408.              }
  1409.           }
  1410.        
  1411.        switch(V33)
  1412.          {case ZCRCE:
  1413.              WriteLongMsg("ZCRCE: Pos=",V102);
  1414.              break;
  1415.           case ZCRCW:
  1416.              WriteLongMsg("ZCRCW: Pos=",V102);
  1417.              break;
  1418.           case ZCRCG:
  1419.              WriteLongMsg("ZCRCG: Pos=",V102);
  1420.              break;
  1421.           default:
  1422.              WriteLongMsg("ZCRC?: Pos=",V102);
  1423.          }
  1424.        
  1425.        V135(V100,V8,(BYTE)V33);
  1426.        V102 = V102 + V8;
  1427.        V34++;
  1428.        if((V5 < V50) && (V34 > V35))
  1429.           {if((V5 << 1) < V50)
  1430.                 V5 = (V5 << 1);
  1431.            else
  1432.                 V5 = V50;
  1433.            V34 = 0;
  1434.           }
  1435.        if(V33 == ZCRCW)  goto V104;
  1436.  
  1437.        SioDelay(5); 
  1438.        
  1439.        while(SioRxQue(V63) )
  1440.           {switch( V110(1) )
  1441.               {case CAN:
  1442.                case ZPAD:
  1443.                    WriteMsg("Trouble?");
  1444.                    SioTxClear(V63);
  1445.                    V135(V100,0,ZCRCE);
  1446.                    goto V104;
  1447.                 case RCDO:
  1448.                    return ZERROR;
  1449.             } 
  1450.          } 
  1451.       } while (V33 == ZCRCG);
  1452.    
  1453.    do
  1454.      {V120(V102);
  1455.       WriteMsg("Sending EOF");
  1456.       V131(ZEOF,V101);
  1457.       SioDelay(5); 
  1458.       c = V86();
  1459.       switch( c )
  1460.          {case ZACK:
  1461.              break;
  1462.           case ZRPOS:
  1463.              goto V80;
  1464.           case ZRINIT:
  1465.              return ZOK;
  1466.           case ZSKIP:
  1467.              return c;
  1468.           default:
  1469. V60:        return ZERROR;
  1470.          } 
  1471.    } while (c == ZACK);
  1472.  return c;
  1473. }
  1474.  
  1475.  
  1476.  
  1477. int V137(void)
  1478. {int  i, c;
  1479.  V23 = 0;
  1480.  do
  1481.    {if(kbhit()) if(getch() == ABORT_CHAR)
  1482.        {V133();
  1483.         WriteMsg(AbortedMsg);
  1484.         return ZERROR;
  1485.        }
  1486.     if(!V105())
  1487.        {WriteMsg("Lost carrier:3");
  1488.         return ZERROR;
  1489.        }
  1490.     for(i=0;i<4;i++) V101[i] = 0;
  1491.     V101[ZF0] = ZCRESUM; 
  1492.     V131(ZFILE,V101);
  1493.     V135(V100,ZBUFSIZE,ZCRCW);
  1494.     do
  1495.        {c = V111(V70);
  1496.         switch( c )
  1497.            {case ZCAN:
  1498.             case RCDO:
  1499.             case ZTIMEOUT:
  1500.             case ZFIN:
  1501.             case ZABORT:
  1502.                return ZERROR;
  1503.             case ZRINIT:
  1504.                break;
  1505.             case ZCRC:
  1506.                V120(V106(V44));
  1507.                V139(ZCRC,V101);
  1508.                break;
  1509.             case ZSKIP:
  1510.                return c;
  1511.             case ZRPOS:
  1512.                if(lseek(V44,V71,SEEK_SET)<0)
  1513.                   {WriteLongMsg("File positioning error to ",V71);
  1514.                    V139(ZFERR,V101);
  1515.                    return ZERROR;
  1516.                   }
  1517.                WriteLongMsg("Setting start position =",V71);
  1518.                V82 = V71;
  1519.                V102 = V71;
  1520.                return V138();
  1521.            } 
  1522.        } while (c == ZRINIT);
  1523.    } while (TRUE);
  1524. }
  1525.  
  1526.  
  1527.  
  1528. BOOL V129(int V62,char *TheFile,BOOL LastFile)
  1529. {int i, n;
  1530.  long V96;
  1531.  char V87[STRING_SIZE];
  1532.  
  1533.  V13 = UseCrc32;
  1534.  V23 = 0;
  1535.  V63 = V62;
  1536.  if(!V105())
  1537.     {WriteMsg("Lost carrier:4");
  1538.      SioDelay(V99);
  1539.      return FALSE;
  1540.     }
  1541.  if(!FileSDT(TheFile,&V26,&V27,&V31))
  1542.     {sprintf(V87,"Unable to open(2) %s",TheFile);
  1543.      WriteMsg(V87);
  1544.      V136();
  1545.      return FALSE;
  1546.     }
  1547.  sprintf(V87,"Sending %s, size=%ld",TheFile,V26);
  1548.  WriteMsg(V87);
  1549.  if(V26==0L)
  1550.     {WriteMsg("File is empty!");
  1551.      SioDelay(V59);
  1552.      return FALSE;
  1553.     }
  1554.  
  1555.  for(i=0;i<ZBUFSIZE;i++) V100[i] = '\0';
  1556.  n = strlen(TheFile);
  1557.  for(i=0;i<n;i++) V28[i] = tolower(TheFile[i]);
  1558.  V28[i] = '\0';
  1559.  sprintf(V100,"%s %ld ",V28,V26);
  1560.  Dos2Zdate(V27,V31,V87,STRING_SIZE);
  1561.  strcat(V100,V87);
  1562.  V100[n] = '\0';
  1563.  V72 = 10 * V59;
  1564.  V3[0] = 'r';
  1565.  V3[1] = 'z';
  1566.  V3[2] = 13;
  1567.  V3[3] = 0;
  1568.  V121(V3);
  1569.  for(i=0;i<ZATTNLEN;i++) V3[i] = 0;
  1570.  V120(0L);
  1571.  V139(ZRQINIT,V101);
  1572.  if(V85() == ZERROR) return FALSE;
  1573.  V44 = open(V28,O_RDONLY|O_BINARY,S_IREAD);
  1574.  if(V44<0)
  1575.     {sprintf(V87,"Cannot open '%s'",V28);
  1576.      WriteMsg(V87);
  1577.      V133();
  1578.      return FALSE;
  1579.     }
  1580.  
  1581.  V96 = SioTimer();
  1582.  n = V137();
  1583.  WriteCPS(V96,V26,V28,(n==ZSKIP));
  1584.  close(V44);
  1585.  if(LastFile)  V136();
  1586.  if(n==ZERROR) return FALSE;
  1587.  else return TRUE;
  1588. }
  1589.  
  1590.  
  1591.  
  1592. BOOL ZmodemTx(int V62, char *V29,int V83)
  1593. {char V95[15];
  1594.  char V57[15];
  1595.  BOOL V46;
  1596.  BOOL V64;
  1597.  char V87[40];
  1598.  V84 = V83;
  1599.  V64 = FALSE;
  1600.  V46 = FALSE;
  1601.  
  1602.  if(!FetchName(V29)) return FALSE;
  1603.  
  1604.  if(!FindFirst(V29,V95,NULL))
  1605.    {sprintf(V87,"Cannot open %s",V29);
  1606.     WriteMsg(V87);
  1607.     return FALSE;
  1608.    }
  1609.  
  1610.  do
  1611.     {if(!FindNext(V57,NULL)) V46 = TRUE;
  1612.      sprintf(V87,"Sending %s",V95);
  1613.      WriteMsg(V87);
  1614.      SioDelay(V90+ZDELAY);
  1615.      V64 = V129(V62,V95,V46);
  1616.      if(!V64) break;
  1617.      if(!V46) strcpy(V95,V57);
  1618.     } while (!V46);
  1619.  if(V64) WriteMsg("ZMODEM completed");
  1620.  else WriteMsg("ZMODEM failed");
  1621.  ModemQuiet(V62,9);
  1622.  return V64;
  1623. }
  1624.  
  1625.  
  1626.  
  1627. BOOL ZmodemRx(int V62,int V83)
  1628. {BOOL V64;
  1629.  V84 = V83;
  1630.  V64 = V125(V62);
  1631.  if(V64) WriteMsg("ZMODEM completed");
  1632.  else WriteMsg("ZMODEM failed");
  1633.  ModemQuiet(V62,9);
  1634.  return V64;
  1635. }
  1636.