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