home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 066.lha / Zterm / term.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-11-20  |  17.8 KB  |  717 lines

  1.             /* Create xrb - xmodem_request_block */
  2. /*lint -e544 (ignore stuff after #endif) */
  3.                         /* a not so simple terminal program */
  4.                                    /* Nik Conwell */
  5. #define MAIN_MODULE 1
  6.  
  7. #include "term.h"                  /* Defines */
  8. #include "term.data"               /* Data Seg for this prg */
  9. #include "term.common"             /* Common segment */
  10.  
  11. struct IntuitionBase *IntuitionBase;
  12. struct GfxBase *GfxBase;
  13. struct Z_Term *zt;
  14.  
  15. main()
  16. {
  17.  zt = (struct Z_Term *)
  18.           AllocMem(sizeof(*zt),MEMF_PUBLIC|MEMF_CLEAR); 
  19.  
  20.  open_libraries();            /* Open up good libs */
  21.  create_console(zt);          /* Create stuff for console */
  22.  create_ser_device(zt);       /* Create stuff for modem */
  23.  create_timer_device(zt);       /* Create stuff for sys timer */
  24.  
  25. /* set bit masks, so that we are awakened when these bits are set */
  26.  
  27.  zt->consolereadbit = zt->consolereadport->mp_SigBit;
  28.  zt->w1_intuitionmsgbit = zt->w1->UserPort->mp_SigBit;
  29.  zt->serialipbit = zt->read_request->IOSer.io_Message.mn_ReplyPort->mp_SigBit;
  30.  
  31. /* Do misc inits */
  32.  zt->prev_alg = 0;
  33.  zt->prev_baud = 0;
  34.  zt->prev_blocksize = 0;
  35.   
  36.  
  37.  con_put_str("Amiga Terminal Active.\n",zt);
  38.  
  39.  do
  40.  {
  41.   zt->wakeupmask = Wait(W1_INTUITION_MESSAGE |
  42.                     TYPED_CHARACTER |
  43.                     SERIAL_INPUT);
  44.  
  45. /* The console (read) woke us up */
  46.  
  47.  if (zt->wakeupmask & TYPED_CHARACTER)
  48.     {
  49.      GetMsg(zt->consolereadport);
  50.      zt->rs_out = zt->iletter;
  51.      DoIO(zt->write_request);
  52. /* put code for echo here */
  53.      queue_read(zt);
  54.     }
  55.  
  56. /* Input from the serial port woke us up. */
  57.  
  58.  if (zt->wakeupmask & SERIAL_INPUT)
  59.     {
  60.      WaitIO(zt->read_request);
  61.      zt->oletter = zt->rs_in & 0x7f;
  62.      BeginIO(zt->read_request);
  63.      con_put_char(zt->oletter,zt);
  64.      if (zt->rf == 1)    /* have the receive file switch on ?? */
  65.         {
  66.          zt->st = write(zt->f1,&(zt->oletter),1);
  67.         }
  68.     }  /* end if */
  69.  
  70.  
  71. /* Intuition woke us up on window 1. */
  72.  
  73.   if (zt->wakeupmask & W1_INTUITION_MESSAGE)
  74.     {
  75.        while ((zt->message = (struct IntuiMessage *)
  76.                GetMsg(zt->w1->UserPort)) != NULL)
  77.           {
  78.            handle_intui_message(zt);
  79.            if ((zt->class == MENUPICK) && (zt->code != MENUNULL))
  80.               {
  81.                handle_menu(zt);
  82.               }  /* end if class == valid menupick */
  83.           }  /* end while there is something on w1's port */
  84.     }  /* end if wakeupmask says intuition woke us up */
  85.  
  86.  } while (zt->class != CLOSEWINDOW);  /* end do while */
  87.  
  88.  
  89.   /* do the closing cleanup crap */
  90.  getout(FAIL_NO_FAIL,zt);
  91.  
  92. }
  93.  
  94. /* some functions that we need */
  95.  
  96. void queue_read(zt)
  97.     struct Z_Term *zt;
  98.     {
  99.      zt->consolereadmsg->io_Command = CMD_READ;
  100.      zt->consolereadmsg->io_Data = (APTR) &(zt->iletter);
  101.      zt->consolereadmsg->io_Length = 1;
  102.      SendIO(zt->consolereadmsg);
  103.     }  /* end queue_read(zt) */
  104.  
  105. void con_put_char(character,zt)
  106.      char character;
  107.      struct Z_Term *zt;
  108.     {
  109.      zt->consolewritemsg->io_Command = CMD_WRITE;
  110.      zt->consolewritemsg->io_Data = (APTR) &character;
  111.      zt->consolewritemsg->io_Length = 1;
  112.      DoIO(zt->consolewritemsg);
  113.     }  /* end con_put_char */
  114.  
  115.  
  116.  
  117.  
  118.  
  119. void con_put_str(string,zt)
  120.     char *string;
  121.     struct Z_Term *zt;
  122.    {
  123.     zt->consolewritemsg->io_Command = CMD_WRITE;
  124.     zt->consolewritemsg->io_Data = (APTR) string;
  125.     zt->consolewritemsg->io_Length = -1;
  126.     DoIO(zt->consolewritemsg);
  127.    }  /* end con_put_str() */
  128.  
  129.  
  130.  
  131.  
  132.  
  133. /* Copy needed fields from intui_message, then reply immediately */
  134.  
  135. void handle_intui_message(zt)
  136.  
  137. struct Z_Term *zt;
  138.  
  139. {
  140.  zt->class = zt->message->Class;
  141.  zt->code = zt->message->Code;
  142.  zt->qualifier = zt->message->Qualifier;
  143.  zt->address = zt->message->IAddress;
  144.  ReplyMsg(zt->message);
  145. }  /* end handle_intui_message(zt) */
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153. /* Handle processing for menu items selected */
  154.  
  155. void handle_menu(zt)
  156.  
  157. struct Z_Term *zt;
  158.  
  159. {
  160.  zt->menunum = MENUNUM(zt->code);
  161.  zt->menuitem = ITEMNUM(zt->code);
  162.  switch(zt->menunum)
  163.   {
  164.    case MENU_PROJECT  : switch(zt->menuitem)
  165.              {
  166.               case MENU_PROJECT_INFO : 
  167.                        AutoRequest(zt->w1,
  168.                            &AboutText[0],
  169.                    NULL,
  170.                    &OKText,0,0,315,100);
  171.                        break;
  172.               case MENU_PROJECT_QUIT :
  173.                        zt->class = CLOSEWINDOW;
  174.                        break;
  175.              }
  176.             break;
  177.    case MENU_BAUD : handle_baud(zt);
  178.                     break;
  179.    case MENU_FILESTUFF  : switch(zt->menuitem)
  180.              {
  181.               case MENU_FILESTUFF_SEND_XMODEM :
  182.                     getfilename(zt->filename); 
  183.                        if (zt->filename[0] == NULL)
  184.                           {
  185.                            break;
  186.                           }
  187.                        xmodem_send_file(zt);
  188.                        break;
  189.               case MENU_FILESTUFF_READ_XMODEM :
  190.                        getfilename(zt->filename);
  191.                        if (zt->filename[0] == NULL)
  192.                           {
  193.                            break;
  194.                           }  
  195.                        xmodem_read_file(zt);
  196.                        break;
  197.               case MENU_FILESTUFF_RECEIVE_TEXT :
  198.                        getfilename(zt->filename);
  199.                        if (zt->filename[0] == NULL)
  200.                           {
  201.                            break;
  202.                           }
  203.                        if ((zt->f1 = creat(zt->filename,NULL)) < NULL)
  204.                           {
  205.                            con_put_str("\nCannot open rcv file - Exists.\n",zt);
  206.                           }
  207.                        else
  208.                           {
  209.                            zt->rf = 1;                   
  210.                           }
  211.                        break;
  212.               case MENU_FILESTUFF_RECEIVE_TEXT_END : 
  213.                        if (zt->rf == 1)
  214.                          {
  215.                           zt->rf = 0;
  216.                           close(zt->f1);
  217.                           break;
  218.                          }
  219.               case MENU_FILESTUFF_SEND_TEXT : 
  220.                        getfilename(zt->filename);
  221.                        if (zt->filename[0] == 0)
  222.                           {
  223.                            break;
  224.                           }
  225.                        type(zt);
  226.                        break;
  227.             }  /* end switch (menuitem) */
  228.             break;
  229.    case MENU_XMODEM_OPTIONS : set_xmodem_options(zt);
  230.                      break;
  231.  
  232.   }  /* end of menunum switch */
  233. }  /* end of handle_menu() */
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240. void type(zt)
  241. struct Z_Term *zt;
  242.  
  243. {
  244. char ch;    /* character read from the file */
  245.  
  246.   if ((zt->f2 = fopen(zt->filename,"r")) == NULL)
  247.      {
  248.       con_put_str("\nCannot open send file. - Not found.\n");
  249.      }  /* end if the file open was not ok */
  250.   else
  251.      {
  252.       while ((ch = getc(zt->f2)) != EOF)
  253.        {
  254.         sendchar((char) ch,zt);
  255.         if ((zt->message = (struct IntuiMessage *)
  256.              GetMsg(zt->w1->UserPort)) != NULL)
  257.           {
  258.            handle_intui_message(zt);
  259.            if ((zt->class == MENUPICK) && (zt->code != MENUNULL))
  260.              {
  261.               zt->menunum = MENUNUM(zt->code);
  262.               zt->menuitem = ITEMNUM(zt->code);
  263.               if ((zt->menunum == MENU_FILESTUFF) && 
  264.                   (zt->menuitem == MENU_FILESTUFF_ABORT_XMODEM))
  265.                {
  266.                 con_put_str("\nUser Cancelled Text Send.\n",zt);
  267.                 break;   /* break out of the while loop */
  268.                }  /* end if we have the correct menu item */
  269.              }  /* end if the message signifies menu playness */
  270.           }  /* end if there something on the message port */
  271.        }  /* end while there is another char to send */
  272.       if ((zt->st = fclose(zt->f2)) == -1)
  273.          {
  274.           con_put_str("\nCouldn't close send file.\n",zt);
  275.          }  /* end if close was not ok */      
  276.      }  /* end else (if file open was ok) */
  277. }  /* end type() */
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284. /* Change the baud rate specified */
  285.  
  286. void handle_baud(zt)
  287.  
  288. struct Z_Term *zt;
  289.  
  290. {
  291.  char baud_notify[80];
  292.  char baud_alpha[BAUD_ALPHA_LEN];
  293.  switch(zt->menuitem)
  294.    {
  295.     case 0 : zt->baud=110;
  296.              break;
  297.     case 1 : zt->baud=300;
  298.              break;
  299.     case 2 : zt->baud=1200;
  300.              break;
  301.     case 3 : zt->baud=2400;
  302.              break;
  303.     case 4 : zt->baud=4800;
  304.              break;
  305.     case 5 : zt->baud=9600;
  306.              break;
  307.     case 6 : zt->baud=19200;
  308.              break;
  309.     case 7 : zt->baud=31250;
  310.              break;
  311.              }
  312.  
  313.   strcpy(baud_notify,"\nBaud changed to ");
  314.   stci_d(baud_alpha,zt->baud,BAUD_ALPHA_LEN);
  315.   strcat(baud_notify,baud_alpha);
  316.   strcat(baud_notify,"\n");
  317.   con_put_str(baud_notify,zt);
  318.  
  319.   remove_ser_1(zt);       /* remove 1'st part of ser device */
  320.   remove_ser_2(zt);       /* remove 2'nd part of ser device */
  321.   create_ser_device(zt);  /* recreate the dev again */
  322.   fix_menu(zt);
  323. }  /* End handle_baud(zt) */
  324.  
  325. void open_libraries()
  326.  
  327. /* Open up system libraries  (Dos already opened) */
  328. {
  329.  
  330.  IntuitionBase = (struct IntuitionBase *)
  331.                  OpenLibrary("intuition.library",INTUITION_REV);
  332.  
  333.  if (IntuitionBase == NULL)
  334.     {
  335. #ifdef DEBUG
  336.      printf("Cannot open Intuition.\n");
  337. #endif
  338.      getout(FAIL_INTUITION_OPEN,zt);
  339.     }
  340.  GfxBase = (struct GfxBase *) 
  341.            OpenLibrary("graphics.library",GRAPHICS_REV);
  342.  if (GfxBase == NULL)
  343.     {
  344. #ifdef DEBUG
  345.      printf("Cannot open graphics library.\n");
  346. #endif
  347.      getout(FAIL_GRAPHICS_OPEN,zt);
  348.     }
  349. }
  350.  
  351. void create_console(zt)
  352.  
  353. struct Z_Term *zt;
  354.  
  355. /* Create a path to the user */
  356. {
  357.  zt->w1 = (struct Window *) OpenWindow(&NewWindowStructure);
  358.  if (zt->w1 == NULL)
  359.     {
  360. #ifdef DEBUG
  361.      gripe("Cannot open window.","","");
  362. #endif
  363.      getout(FAIL_W1_WINDOW_OPEN,zt);
  364.     }
  365.  
  366. /* Set up the Menu */
  367.  
  368.  SetMenuStrip(zt->w1,(struct Menu *) &MenuList);
  369.  
  370.  zt->consolewriteport = (struct MsgPort *) 
  371.                     CreatePort("term.con.write.port",NULL);
  372.  if (zt->consolewriteport == NULL)
  373.     {
  374. #ifdef DEBUG
  375.      gripe("Cannot open console write port.","","");
  376. #endif
  377.      getout(FAIL_CONSOLEWRITEPORT_OPEN,zt);
  378.     }
  379.  zt->consolewritemsg = (struct IOStdReq *) 
  380.                        CreateStdIO(zt->consolewriteport);
  381.  if (zt->consolewritemsg == NULL)
  382.     {
  383. #ifdef DEBUG
  384.      gripe("Cannot open write path.","","");
  385. #endif
  386.      getout(FAIL_CONSOLEWRITESTDIO_OPEN,zt);
  387.     }
  388.  zt->consolereadport = (struct MsgPort *)
  389.                        CreatePort("term.con.read.port",NULL);
  390.  if (zt->consolereadport == 0)
  391.     {
  392. #ifdef DEBUG
  393.      gripe("Cannot open console read port.","","");
  394. #endif
  395.      getout(FAIL_CONSOLEREADPORT_OPEN,zt);
  396.     }
  397.  
  398.  zt->consolereadmsg = (struct IOStdReq *) 
  399.                       CreateStdIO(zt->consolereadport);
  400.  if (zt->consolereadmsg == 0)
  401.     {
  402. #ifdef DEBUG
  403.      gripe("Cannot open console read path.","","");
  404. #endif
  405.      getout(FAIL_CONSOLEREADSTDIO_OPEN,zt);
  406.     }
  407.  
  408.  zt->consolewritemsg->io_Data = (APTR) zt->w1;
  409.  zt->consolewritemsg->io_Length = sizeof(*(zt->w1));
  410.  
  411.  if (OpenDevice("console.device",NULL,zt->consolewritemsg,NULL))
  412.    {
  413. #ifdef DEBUG
  414.      gripe("Couldn't open up console total.\n");
  415. #endif
  416.      getout(FAIL_CONSOLE_OPEN,zt);
  417.    }
  418.  
  419.  zt->consolereadmsg->io_Device = zt->consolewritemsg->io_Device;
  420.  zt->consolereadmsg->io_Unit = zt->consolewritemsg->io_Unit;
  421.  queue_read(zt);
  422.  
  423. }  /* end create_console() */
  424.  
  425.  
  426.  
  427.  
  428.  
  429. void create_ser_device(zt)
  430.  
  431. struct Z_Term *zt;
  432.  
  433. /* Create path to the modem */
  434. {
  435. zt->read_request = (struct IOExtSer *)
  436.                  AllocMem(sizeof(*(zt->read_request)),MEMF_PUBLIC|MEMF_CLEAR);
  437. zt->read_request->io_SerFlags = SERF_SHARED | SERF_XDISABLED;
  438. zt->read_request->IOSer.io_Message.mn_ReplyPort = (struct MsgPort *)
  439.                   CreatePort("term.ser.read.port",NULL);
  440.  
  441.  if (OpenDevice(SERIALNAME,NULL,zt->read_request,NULL))
  442.    {
  443. #ifdef DEBUG
  444.     gripe("Failed to open read serial.device.","","");
  445. #endif
  446.     getout(FAIL_SERIAL_READ_OPEN,zt);
  447.    }  /* end if */
  448.  
  449.  zt->write_request = (struct IOExtSer *)
  450.                  AllocMem(sizeof(*(zt->write_request)),MEMF_PUBLIC|MEMF_CLEAR);
  451.  zt->write_request -> io_SerFlags = SERF_SHARED|SERF_XDISABLED;
  452.  zt->write_request -> IOSer.io_Message.mn_ReplyPort = (struct MsgPort *)
  453.                   CreatePort("term.ser.write.port",NULL);
  454.  
  455.  if (OpenDevice(SERIALNAME,NULL,zt->write_request,NULL))
  456.     {
  457. #ifdef DEBUG
  458.      gripe("Failed to open write serial.device.");
  459. #endif
  460.      getout(FAIL_SERIAL_WRITE_OPEN,zt);
  461.     }  /* end if */
  462.  
  463.  zt->write_request->IOSer.io_Command = CMD_WRITE;
  464.  zt->write_request->IOSer.io_Length = 1;
  465.  zt->write_request->IOSer.io_Data = (APTR) &(zt->rs_out);
  466.  
  467.  zt->read_request->io_SerFlags = SERF_SHARED|SERF_XDISABLED;
  468.  zt->read_request->io_Baud = zt->baud;
  469.  zt->read_request->io_ReadLen = 8;
  470.  zt->read_request->io_WriteLen = 8;
  471.  zt->read_request->io_CtlChar = 1L;
  472.  zt->read_request->IOSer.io_Command = SDCMD_SETPARAMS;
  473.  DoIO(zt->read_request);
  474.  
  475.  zt->read_request->IOSer.io_Command = CMD_READ;
  476.  zt->read_request->IOSer.io_Length = 1;
  477.  zt->read_request->IOSer.io_Data = (APTR) &(zt->rs_in);
  478.  BeginIO(zt->read_request);
  479. }  /* end create_ser_device(zt) */
  480.  
  481.  
  482.  
  483.  
  484. /* Create the interface to the system timer */
  485.  
  486. void create_timer_device(zt)
  487.  
  488. struct Z_Term *zt;
  489.  
  490. {
  491.  if ((zt->timerport = (struct MsgPort *) 
  492.                       CreatePort(NULL,NULL)) == NULL)
  493.    {
  494. #ifdef DEBUG
  495.     gripe("Could not create timer port.","","");
  496. #endif
  497.     getout(FAIL_TIMER_CREATE_PORT,zt);
  498.    }
  499.  if ((zt->timermsg = (struct IOStdReq *) 
  500.                      CreateStdIO(zt->timerport)) == NULL)
  501.    {
  502. #ifdef DEBUG
  503.     gripe("Could not open timer stdio.","","");
  504. #endif
  505.     getout(FAIL_TIMER_CREATE_STDIO,zt);
  506.    }
  507.  if (OpenDevice(TIMERNAME,UNIT_VBLANK,zt->timermsg,0) != NULL)
  508.    {
  509. #ifdef DEBUG
  510.     gripe("Could not open timer device.","","");
  511. #endif
  512.     getout(FAIL_TIMER_OPEN_DEVICE,zt);
  513.    }
  514. }  /* end create_timer_device */
  515.  
  516.  
  517.  
  518.  
  519.  
  520. void getout(fail_code,zt)
  521.  
  522. /* Process exit program requests */
  523.  
  524. int fail_code;
  525. struct Z_Term *zt;
  526.  
  527. {
  528.  if (fail_code > FAIL_TIMER_OPEN_DEVICE)
  529.   {
  530.    AbortIO(zt->timermsg);
  531.    CloseDevice(zt->timermsg);
  532.   }
  533.  if (fail_code > FAIL_TIMER_CREATE_STDIO)
  534.   {
  535.    DeleteStdIO(zt->timermsg);
  536.   }
  537.  if (fail_code > FAIL_TIMER_CREATE_PORT)
  538.   {
  539.    DeletePort(zt->timerport);
  540.   }
  541.  if (fail_code > FAIL_SERIAL_WRITE_OPEN)
  542.   {
  543.    remove_ser_1(zt);
  544.   }
  545.  if (fail_code > FAIL_SERIAL_READ_OPEN)
  546.    {
  547.     remove_ser_2(zt);
  548.     CloseDevice(zt->consolewritemsg);
  549.    }
  550.  if (fail_code > FAIL_CONSOLE_OPEN)
  551.    {
  552.     ClearMenuStrip(zt->w1);
  553.     DeleteStdIO(zt->consolereadmsg);
  554.    }
  555.  if (fail_code > FAIL_CONSOLEREADSTDIO_OPEN)
  556.    {
  557.     DeletePort(zt->consolereadport);
  558.    }
  559.  if (fail_code > FAIL_CONSOLEREADPORT_OPEN)
  560.    {
  561.     DeleteStdIO(zt->consolewritemsg);
  562.    }
  563.  if (fail_code > FAIL_CONSOLEWRITESTDIO_OPEN)
  564.    {
  565.     DeletePort(zt->consolewriteport);
  566.    }
  567.  if (fail_code > FAIL_CONSOLEWRITEPORT_OPEN)
  568.    {    
  569.     CloseWindow(zt->w1);
  570.    }
  571.  if (fail_code > FAIL_W1_WINDOW_OPEN)
  572.    {
  573.     CloseLibrary(GfxBase);
  574.    }
  575.  if (fail_code > FAIL_GRAPHICS_OPEN)
  576.    {
  577.     CloseLibrary(IntuitionBase);
  578.    }
  579.  FreeMem(zt,sizeof(*zt));
  580.  exit(fail_code);
  581. }
  582.  
  583. void remove_ser_1(zt)
  584.  
  585. struct Z_Term *zt;
  586.  
  587. /* remove serial device - part 1 */
  588. {
  589.  AbortIO(zt->read_request);
  590.  AbortIO(zt->write_request);
  591.  CloseDevice(zt->read_request);
  592.  CloseDevice(zt->write_request);
  593.  DeletePort(zt->write_request->IOSer.io_Message.mn_ReplyPort);
  594.  FreeMem(zt->write_request,sizeof(*(zt->write_request)));
  595. }  /* end remove_ser_1(zt) */
  596.  
  597.  
  598.  
  599. void remove_ser_2(zt)
  600.  
  601. struct Z_Term *zt;
  602.  
  603. /* remove serial device - part 2 */
  604.  
  605. {
  606.  DeletePort(zt->read_request->IOSer.io_Message.mn_ReplyPort);
  607.  FreeMem(zt->read_request,sizeof(*(zt->read_request)));
  608. }  /* End remove_ser_2() */
  609.  
  610.  
  611.  
  612.  
  613. void set_timer(time_wait,zt)
  614.  
  615. /* Tell system to return this msg to us when the time is up */
  616.  
  617. int time_wait;
  618. struct Z_Term *zt;
  619.  
  620. {
  621.  AbortIO(zt->timermsg);                         /* Trash outstandings */
  622.  zt->timermsg->io_Command = TR_ADDREQUEST;
  623.  zt->timermsg->io_Actual = time_wait;           /* Wait n seconds */
  624.  zt->timermsg->io_Length = 0;
  625.  SendIO(zt->timermsg);
  626. }  /* End set_timer() */
  627.  
  628. void set_xmodem_options(zt)
  629.  
  630. struct Z_Term *zt;
  631.  
  632. {
  633.  switch (zt->menuitem)
  634.   {
  635.    case MENU_XMODEM_OPTIONS_128_BLOCK    
  636.         :    zt->xfer_blocksize = XMODEM_128_BLOCK;
  637.             con_put_str("\nXfer Blocksize set at 128 bytes.\n",zt);
  638.             break;
  639.    case MENU_XMODEM_OPTIONS_1024_BLOCK    
  640.         :    zt->xfer_blocksize = XMODEM_1024_BLOCK;
  641.             con_put_str("\nXfer Blocksize set at 1024 bytes.\n",zt);
  642.                break;
  643.    case MENU_XMODEM_OPTIONS_CHECKSUM    
  644.         :    zt->xfer_error_detect_alg = XMODEM_CHECKSUM;
  645.             con_put_str("\nXfer error detect alg set to Checksum.\n",zt);
  646.                break;
  647.    case MENU_XMODEM_OPTIONS_CRC16    
  648.         :    zt->xfer_error_detect_alg = XMODEM_CRC16;
  649.             con_put_str("\nXfer error detect alg set to CRC-16.\n",zt);
  650.                break;
  651.   }
  652.  
  653.  fix_menu(zt);
  654. }  /* end set_xmodem_options */
  655.  
  656.  
  657.  
  658.  
  659.  
  660. /* Redo checked portions of the menu strip */
  661.  
  662. fix_menu(zt)
  663.  
  664.  
  665. struct Z_Term *zt;
  666.  
  667. {
  668.  ClearMenuStrip(zt->w1);
  669.  
  670. /* Uncheck previous selection menu items */
  671. /* This selection will be checked by Intuition */
  672.  if (zt->prev_baud != zt->baud)
  673.   {
  674.    switch(zt->prev_baud)
  675.     {
  676.      case 110:   MenuItem12.Flags &= ~CHECKED;
  677.                  break;
  678.      case 300:   MenuItem13.Flags &= ~CHECKED;
  679.                  break;
  680.      case 1200:  MenuItem14.Flags &= ~CHECKED;
  681.                  break;
  682.      case 2400:  MenuItem15.Flags &= ~CHECKED;
  683.                  break;
  684.      case 4800:  MenuItem16.Flags &= ~CHECKED;
  685.                  break;
  686.      case 9600:  MenuItem17.Flags &= ~CHECKED;
  687.                  break;
  688.      case 19200: MenuItem18.Flags &= ~CHECKED;  
  689.                  break;
  690.      case 31250: MenuItem19.Flags &= ~CHECKED;
  691.     }
  692.    zt->prev_baud = zt->baud;
  693.   }
  694.  
  695.  if (zt->prev_alg != zt->xfer_error_detect_alg)
  696.   {
  697.    if (zt->prev_alg == XMODEM_CRC16)
  698.       MenuItem4.Flags &= ~CHECKED;
  699.  
  700.    if (zt->prev_alg == XMODEM_CHECKSUM)
  701.       MenuItem3.Flags &= ~CHECKED;
  702.    zt->prev_alg = zt->xfer_error_detect_alg;
  703.   }
  704.  
  705.  if (zt->prev_blocksize != zt->xfer_blocksize)
  706.   {
  707.    if (zt->prev_blocksize == XMODEM_1024_BLOCK)
  708.       MenuItem2.Flags &= ~CHECKED;
  709.  
  710.    if (zt->prev_blocksize == XMODEM_128_BLOCK)
  711.       MenuItem1.Flags &= ~CHECKED;
  712.    zt->prev_blocksize = zt->xfer_blocksize;
  713.   }
  714.  
  715.  SetMenuStrip(zt->w1,(struct Menu *) &MenuList);
  716. }  /* End fix_menu() */
  717.