home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / wps / com / c_kermit / sources / ckopm3.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-01-01  |  21.7 KB  |  719 lines

  1. /******************************************************************************
  2. File name:  ckopm3.c    Rev: 01  Date: 22-Mar-90 Programmer: C.P.Armstrong
  3.  
  4. File title: Yet more functions which can't be fitted into ckopm1 or ckopm2
  5.             because of the idiot memory restrictions present in V5.1 of
  6.             MS C.  These problems primarily seem to be associated with the
  7.             enormous OS/2 include files!
  8.             
  9.             This file contains mostly menu and dialog functions.
  10.  
  11. Contents:   
  12.  
  13. Modification History:
  14.     01  22-Mar-90   C.P.Armstrong   created
  15.  
  16. ******************************************************************************/
  17. #define INCL_WIN
  18. #define INCL_GPI 
  19. #define INCL_DOS
  20. #define INCL_AVIO
  21. #include <OS2.h>
  22. #include <stdio.h>
  23. #include <stdlib.h>
  24. #include <string.h>
  25. #include "ckorc.h"
  26. #include "ckcker.h"   /* For VT100 and TEKTRONIX */
  27. #include "ckotek.h"   /* For HPGL,TEK,WPG */
  28. #include "ckopm.h"
  29.  
  30. MRESULT EXPENTRY ComsDlgProc(HWND,USHORT,MPARAM,MPARAM);
  31. MRESULT EXPENTRY TermDlgProc(HWND,USHORT,MPARAM,MPARAM);
  32. MRESULT EXPENTRY MiscDlgProc(HWND,USHORT,MPARAM,MPARAM);
  33. int ComsDlgInit(HWND);
  34. int ComsDlgExit(HWND);
  35. int ComsDlgCmnd(HWND,int);
  36. int TermDlgInit(HWND);
  37. int TermDlgExit(HWND);
  38. int TermDlgCmnd(HWND,int);
  39. int MiscDlgInit(HWND);
  40. int MiscDlgExit(HWND);
  41. int MiscDlgCmnd(HWND,int);
  42.  
  43.  
  44. int seslogdlg(HWND);
  45. int tralogdlg(HWND);
  46. int deblogdlg(HWND);
  47. int pktlogdlg(HWND);
  48.  
  49. void cdecl pm_err(char *);          /* declared in ckopm.h.  Redeclared here */
  50. void cdecl pm_msg(char*,char*);     /* to avoid having to include all the    */
  51.                                     /* OS2.H stuff required for ckopm.h in an*/
  52.                                     /* attempt to beat the MSC5.1 out of heap*/
  53.                                     /* messages which occur for tiny files.  */
  54. void buff_insert(int);
  55.  
  56. /******************************************************************************
  57. Function:       menu_routine()
  58.  
  59. Description:    Called when a bottom level menu item is selected
  60.  
  61. Syntax:         int menu_routine(hwndmenu,hwnd,msg,mp1,mp2)
  62.                     HWND hwndmenu;  Handle of the menu
  63.                     HWND hwnd;      Handle of the calling window
  64.                     HVPS hvps;      Handl to Vio presentation space
  65.                     USHORT msg;     Parameters passed to the calling window
  66.                     MPARAM mp1;
  67.                     MPARAM mp2 ;
  68.  
  69. Returns:        0 at present
  70.  
  71. Mods:           22-Mar-90 C.P.Armstrong created
  72.                 01-Apr-90 C.P.Armstrong Edit menu support added. Params now
  73.                                         include an HVPS - which can be null.
  74.  
  75. ******************************************************************************/
  76. int menu_routine(HAB hab,HWND hwndmenu, HWND hwnd, HVPS hvps, 
  77.                  USHORT msg,MPARAM mp1,MPARAM mp2)
  78.     {
  79.     int log_mode;
  80.  
  81.     switch(SHORT1FROMMP(mp1))
  82.         {
  83.         case IDM_TERM:
  84.             WinDlgBox(HWND_DESKTOP,hwnd,TermDlgProc,(HMODULE)0,IDD_TERM,NULL);
  85.             break;
  86.         case IDM_COMMS:
  87.             WinDlgBox(HWND_DESKTOP,hwnd,ComsDlgProc,(HMODULE)0,IDD_COMMS,NULL);
  88.             return(0);
  89.         case IDM_NETWS:
  90.             pm_msg("Coming soon....","Not implimented yet");
  91.             break;
  92.         case IDM_MISC:
  93.             WinDlgBox(HWND_DESKTOP,hwnd,MiscDlgProc,(HMODULE)0,IDD_MISC,NULL);
  94.             return(0);
  95.         case IDM_SESSLOG:
  96.             seslogdlg(hwnd);
  97.             break;
  98.         case IDM_TRNLOG:
  99.             tralogdlg(hwnd);
  100.             return(0);
  101.         case IDM_DEBUG:
  102.             deblogdlg(hwnd);
  103.             return(0);
  104.         case IDM_PAKT:
  105.             pktlogdlg(hwnd);
  106.             return(0);
  107.         case IDM_REMDIR:
  108.             pm_msg("Coming soon....","Do a remote dir");
  109.             break;
  110.         case IDM_REMCD:
  111.             pm_msg("Coming soon....","Do a remote cd");
  112.             break;
  113.         case IDM_SEND:
  114.             pm_msg("Coming soon....","Send file(s)");
  115.             break;
  116.         case IDM_GET:
  117.             pm_msg("Coming soon....","Get file(s)");
  118.             break;
  119.         case IDM_COPY:
  120.             do_copy(1,hvps,hab);
  121.             break;
  122.         case IDM_APP:
  123.             do_copy(2,hvps,hab);
  124.             break;
  125.         case IDM_COPYPASTE:
  126.             do_copy(1,hvps,hab);
  127.         case IDM_PASTE:
  128.             do_paste(hab);
  129.             break;
  130.         case IDM_PRINTG:
  131.             do_print(hab,hwnd);
  132.             break;
  133.         case IDM_METAG:
  134.             do_meta(hab,hwnd);
  135.             break;
  136.         default:
  137.             pm_err("Bad menu message");
  138.             break;
  139.         }
  140.     return(0);
  141.     }
  142.     
  143. int init_menu(MPARAM mp1,HWND hwndMenu,HWND hwnd, HAB hab)
  144.    {
  145.    extern int marking;
  146.    USHORT us;
  147.    
  148.    switch (SHORT1FROMMP (mp1))
  149.         {
  150.         case IDM_EDIT:
  151.              WinSendMsg (hwndMenu, MM_SETITEMATTR,
  152.                          MPFROM2SHORT (IDM_COPY, TRUE),
  153.                          MPFROM2SHORT (MIA_DISABLED,
  154.                               (marking==2) ? 0 : MIA_DISABLED)) ;
  155.  
  156.              WinSendMsg (hwndMenu, MM_SETITEMATTR,
  157.                          MPFROM2SHORT (IDM_APP, TRUE),
  158.                          MPFROM2SHORT (MIA_DISABLED,
  159.                               (marking==2) ? 0 : MIA_DISABLED)) ;
  160.  
  161.              WinSendMsg (hwndMenu, MM_SETITEMATTR,
  162.                          MPFROM2SHORT (IDM_COPYPASTE, TRUE),
  163.                          MPFROM2SHORT (MIA_DISABLED,
  164.                               (marking==2) ? 0 : MIA_DISABLED)) ;
  165.              WinSendMsg (hwndMenu, MM_SETITEMATTR,
  166.                          MPFROM2SHORT (IDM_PASTE, TRUE),
  167.                          MPFROM2SHORT (MIA_DISABLED,
  168.                   WinQueryClipbrdFmtInfo (hab, CF_TEXT, &us)
  169.                                  ? 0 : MIA_DISABLED)) ;
  170.              WinSendMsg (hwndMenu, MM_SETITEMATTR,
  171.                          MPFROM2SHORT (IDM_VIEWCLIP, TRUE),
  172.                          MPFROM2SHORT (MIA_DISABLED,MIA_DISABLED)) ;
  173.  
  174.              return 0 ;
  175.        default:
  176.            return(1);
  177.    
  178.        }
  179.  
  180.    return(1);
  181.    }
  182.  
  183. /******************************************************************************
  184. Function:       TermDlgProc()
  185.  
  186. Description:    Handles the communications parameters dialog.
  187.  
  188. Syntax:         MRESULT EXPENTRY ComsDlgProc(hwnd,msg,mp1,mp2)
  189.                     HWND hwnd       Standard details passed to a 
  190.                     USHORT msg      client procedure
  191.                     MPARAM mp1
  192.                     MPARAM mp2
  193.  
  194. Returns:        0 if message handled or result of WinDefDlgProc
  195.  
  196. Mods:           22-Mar-90 C.P.Armstrong created
  197.  
  198. ******************************************************************************/
  199. MRESULT EXPENTRY TermDlgProc(HWND hwnd, USHORT msg, MPARAM mp1,MPARAM mp2)
  200.     {
  201.     switch(msg)
  202.         {
  203.         case WM_INITDLG:
  204.             TermDlgInit(hwnd);
  205.             return(0);
  206.  
  207.         case WM_COMMAND:
  208.             switch(COMMANDMSG(&msg)->cmd)
  209.                 {
  210.                 case DID_EXIT:
  211.                     TermDlgExit(hwnd);
  212.                 case DID_CANCEL:
  213.                     WinDismissDlg(hwnd,TRUE);
  214.                     return(0);
  215.                 default:
  216.                     break;
  217.                 }
  218.             break;
  219.         case WM_CONTROL:
  220.             if(TermDlgCmnd(hwnd,SHORT1FROMMP(mp1))==0)
  221.                   return(0);
  222.             break;
  223.             
  224.         default:
  225.             break;
  226.         }
  227.     return(WinDefDlgProc(hwnd,msg,mp1,mp2));
  228.     }
  229.  
  230. int TermDlgExit(HWND hwnd)
  231.     {
  232.     extern void ipadl();
  233.     extern int Term_mode;   /* VT100 or TEKTRONIX */
  234.     extern int dump_format; /* Tek dump file,  HPGL, TEK, WPG */
  235.     extern int cmask;       /* 7bit = 0177, 8bit = 0377 */
  236.     extern int conected;
  237.     extern ULONG threadsem; /* Set if in conect mode */
  238.  
  239.     int index;
  240.     int newdf;
  241.  
  242.     index = (int)WinSendDlgItemMsg(hwnd,DID_HPGLDMP,
  243.         BM_QUERYCHECKINDEX,NULL,NULL);
  244.     switch(index)
  245.         {
  246.         case 1:     /* HPGL dump */
  247.             newdf = HPGL;
  248.             break;
  249.         case 2:     /* No plot */
  250.             newdf = NODMP;
  251.             break;
  252.         default:
  253.             newdf = NODMP;
  254.             break;
  255.         }
  256.  
  257.     if( (Term_mode==TEKTRONIX) && (newdf != dump_format) )
  258.         {
  259.         /* Close the current one */
  260.         gfile_close();
  261.         /* set new format and open the dump file */
  262.         dump_format = newdf;
  263.         gfile_open();
  264.         }
  265.     else
  266.         dump_format = newdf;
  267.  
  268.  
  269.  
  270.     index = (int)WinSendDlgItemMsg(hwnd,DID_VT100,BM_QUERYCHECKINDEX,NULL,NULL);
  271.     switch(index)
  272.         {
  273.         case 1:                 /* VT100 selected */
  274.             /* Close previous mode if necessary */
  275.             if(Term_mode == TEKTRONIX)
  276.                 {
  277.                 Tek_finish();
  278.                 }
  279.  
  280.             Term_mode=VT100;
  281.             break;
  282.         case 2:                 /* Tektronix selected */
  283.             /* Close previous mode if necessary */
  284.             if(Term_mode == TEKTRONIX)
  285.                 break;
  286.             
  287.             Term_mode = TEKTRONIX;
  288.             Tek_scrinit(1);
  289.             break;
  290.         default:
  291.             break;
  292.         }       
  293.  
  294.     index = (int)WinSendDlgItemMsg(hwnd,DID_TERM7BIT,
  295.                     BM_QUERYCHECKINDEX,NULL,NULL);
  296.     switch(index)
  297.         {
  298.         case 1:     /* 7bit */
  299.             cmask = 0177;
  300.             break;
  301.         case 2:     /* 8bit */
  302.             cmask = 0377;
  303.             break;
  304.         }
  305.     
  306.     /* Set the status line..... if in connect mode */
  307.     if(conected==1)
  308.         {               /* A kludge to get the conect() thread to update the */
  309.         buff_insert(0); /* status line. Cant do from PM thread because of    */
  310.         }               /* sem deadlock problems. scankey() intercepts a code*/
  311.                         /* of 0 and does an ipadl25()                        */
  312.  
  313.     return(0);
  314.     }
  315.  
  316. int TermDlgInit(HWND hwnd)
  317.     {
  318.     extern int Term_mode;   /* VT100 or TEKTRONIX */
  319.     extern int dump_format; /* Tek dump file,  HPGL, TEK, WPG */
  320.     extern int cmask;       /* 7bit = 0177, 8bit = 0377 */
  321.  
  322.  
  323.     /* Check the current terminal emulation mode */
  324.     switch(Term_mode)
  325.         {
  326.         case VT100:
  327.             WinSendDlgItemMsg(hwnd,DID_VT100,BM_SETCHECK,MPFROMSHORT(1),0L);
  328.             break;
  329.         case TEKTRONIX:
  330.             WinSendDlgItemMsg(hwnd,DID_TEK4014,BM_SETCHECK,MPFROMSHORT(1),0L);
  331.             break;
  332.         default:
  333.             break;
  334.         }
  335.  
  336.     /* Check the current byte size parameter */
  337.     switch(cmask)
  338.         {
  339.         case 0177:
  340.             WinSendDlgItemMsg(hwnd,DID_TERM7BIT,BM_SETCHECK,MPFROMSHORT(1),0L);
  341.             break;
  342.         case 0377:
  343.             WinSendDlgItemMsg(hwnd,DID_TERM8BIT,BM_SETCHECK,MPFROMSHORT(1),0L);
  344.             break;
  345.         default:
  346.             break;
  347.         }
  348.         
  349.     /* Check the current Tektronix dump mode */
  350.     switch(dump_format)
  351.         {
  352.         case NODMP:
  353.             WinSendDlgItemMsg(hwnd,DID_NODMP,BM_SETCHECK,MPFROMSHORT(1),0L);
  354.             break;
  355.         case HPGL:
  356.             WinSendDlgItemMsg(hwnd,DID_HPGLDMP,BM_SETCHECK,MPFROMSHORT(1),0L);
  357.             break;
  358.         case TEK:
  359.             WinSendDlgItemMsg(hwnd,DID_TEKDMP,BM_SETCHECK,MPFROMSHORT(1),0L);
  360.             break;
  361.         case WPG:
  362.             WinSendDlgItemMsg(hwnd,DID_WPGDMP,BM_SETCHECK,MPFROMSHORT(1),0L);
  363.             break;
  364.         default:
  365.             break;
  366.         }
  367.  
  368.     return(0);
  369.     }                                                       
  370.     
  371. int TermDlgCmnd(HWND hwnd,int cmnd)
  372.     {
  373.     return(-1);
  374.     }
  375.  
  376.  
  377.  
  378. /******************************************************************************
  379. Function:       ComsDlgProc()
  380.  
  381. Description:    Handles the communications parameters dialog.
  382.  
  383. Syntax:         MRESULT EXPENTRY ComsDlgProc(hwnd,msg,mp1,mp2)
  384.                     HWND hwnd       Standard details passed to a 
  385.                     USHORT msg      client procedure
  386.                     MPARAM mp1
  387.                     MPARAM mp2
  388.  
  389. Returns:        0 if message handled or result of WinDefDlgProc
  390.  
  391. Mods:           22-Mar-90 C.P.Armstrong created
  392.  
  393. ******************************************************************************/
  394. MRESULT EXPENTRY ComsDlgProc(HWND hwnd, USHORT msg, MPARAM mp1,MPARAM mp2)
  395.     {
  396.     switch(msg)
  397.         {
  398.         case WM_INITDLG:
  399.             ComsDlgInit(hwnd);
  400.             return(0);
  401.  
  402.         case WM_COMMAND:
  403.             switch(COMMANDMSG(&msg)->cmd)
  404.                 {
  405.                 case DID_EXIT:                /* Must come directly before    */
  406.                     if(ComsDlgExit(hwnd)!=0)  /* DID_CANCEL as the DID_CANCEL */
  407.                         break;                /* is used to dismiss the dialog*/
  408.                 case DID_CANCEL:
  409.                     WinDismissDlg(hwnd,TRUE);
  410.                     return(0);
  411.                 default:
  412.                     break;
  413.                 }
  414.             break;
  415.         case WM_CONTROL:
  416.             if(ComsDlgCmnd(hwnd,SHORT1FROMMP(mp1))==0)
  417.                   return(0);
  418.             break;
  419.             
  420.         default:
  421.             break;
  422.         }
  423.     return(WinDefDlgProc(hwnd,msg,mp1,mp2));
  424.     }
  425.     
  426. /******************************************************************************
  427. Function:       ComsDlgExit()
  428.  
  429. Description:    Sets new values for comunications parameters according to
  430.                 the entries made in the dialog.
  431.                 Note that this routine actually opens the new port, having
  432.                 closed any previously opened ports.
  433.  
  434. Syntax:         int ComsDlgExit(HWND hwnd)
  435.  
  436. Returns:        0 if port open successful
  437.                -1 if unsuccessful
  438.  
  439. Mods:           26-Mar-90 C.P.Armstrong created
  440.  
  441. ******************************************************************************/
  442. int ComsDlgExit(HWND hwnd)
  443.     {
  444.     extern int ttnewport(char*);
  445.     extern char ttname[];
  446.     extern int speed;
  447.     extern int odsr;
  448.     extern int idsr;
  449.     extern int octs;
  450.     extern int flow;    /* Hardware handshaking Xon/Xoff=1, none=0 */
  451.     extern char turnch; /* Handshake character */
  452.     extern int parity;  /* Note that 8th-bit prefixing depends on this too */
  453.     extern int conected;
  454.  
  455.     int temp;
  456.     int old_speed,old_octs,old_odsr,old_idsr,old_flow,old_parity;
  457.     char new_port[10];
  458.     
  459.     /* Make copy of the old values so we can reset them if an error occurs */
  460.     old_speed=speed;
  461.     old_octs=octs;
  462.     old_odsr=odsr;
  463.     old_idsr=idsr;
  464.     old_flow=flow;
  465.     old_parity=parity;
  466.  
  467.  
  468.     /* Find which coms port is checked */
  469.     temp = (int)WinSendDlgItemMsg(hwnd,DID_1COM,BM_QUERYCHECKINDEX,NULL,NULL);
  470.     switch(temp)
  471.         {
  472.         case 1:
  473.             strcpy(new_port,"COM1");
  474.             break;
  475.         case 2:
  476.             strcpy(new_port,"COM2");
  477.             break;
  478.         case 3:
  479.             strcpy(new_port,"COM3");
  480.             break;
  481.         default:
  482.             strcpy(new_port,"ERR");
  483.             break;
  484.         }
  485.         
  486.     /* Get the speed */
  487.     WinQueryDlgItemShort(hwnd,DID_BAUD,(PSHORT)&speed,FALSE);
  488.     
  489.     /* The parity */
  490.     temp = (int) WinSendDlgItemMsg(hwnd,DID_EVEN,BM_QUERYCHECKINDEX,NULL,NULL);
  491.     switch(temp)  /* Even,odd,mark,space,none */
  492.         {
  493.         case 1:
  494.             parity='e';
  495.             break;
  496.         case 2:
  497.             parity='o';
  498.             break;
  499.         case 3:
  500.             parity='m';
  501.             break;
  502.         case 4:
  503.             parity='s';
  504.             break;
  505.         case 5:
  506.             parity=0;
  507.             break;
  508.         default:
  509.             parity=0;
  510.             break;
  511.         }
  512.  
  513.  
  514.     /* Do the hardware handshaking */
  515.     temp = (int)WinSendDlgItemMsg(hwnd,DID_XHND,BM_QUERYCHECKINDEX,NULL,NULL);
  516.     switch(temp)  /* hard,xon/xoff */
  517.         {
  518.         case 1:
  519.             flow=0;
  520.             break;
  521.         case 2:
  522.             flow=1;
  523.             break;
  524.         default:
  525.             flow=1;
  526.             break;
  527.         }
  528.     
  529.     /* Do the hardware flow */
  530.     odsr = (int)WinSendDlgItemMsg(hwnd,DID_ODSR,BM_QUERYCHECK,NULL,NULL);
  531.     idsr = (int)WinSendDlgItemMsg(hwnd,DID_IDSR,BM_QUERYCHECK,NULL,NULL);
  532.     octs = (int)WinSendDlgItemMsg(hwnd,DID_OCTS,BM_QUERYCHECK,NULL,NULL);
  533.     
  534.  
  535.     /* Now try to open the port with the new settings */
  536.     if( ttnewport(new_port)!=1)   /* Should check this doesn't happen */
  537.         {                         /* during a transfer!               */
  538.         pm_err("Failed to open port");
  539.         /* Reset the parameters to the original values */
  540.         speed  =    old_speed ;
  541.         octs   =    old_octs  ;
  542.         odsr   =    old_odsr  ;
  543.         idsr   =    old_idsr  ;
  544.         flow   =    old_flow  ;
  545.         parity =    old_parity;
  546.         return(-1);
  547.         }
  548.  
  549.     /* Set the status line..... if in connect mode */
  550.     if(conected==1)
  551.         {               /* A kludge to get the conect() thread to update the */
  552.         buff_insert(0); /* status line. Cant do from PM thread because of    */
  553.         }               /* sem deadlock problems. scankey() intercepts a code*/
  554.  
  555.     return(0);
  556.     }
  557.  
  558. int ComsDlgInit(HWND hwnd)
  559.     {
  560.     extern char ttname[];
  561.     extern int speed;
  562.     extern int odsr;
  563.     extern int idsr;
  564.     extern int octs;
  565.     extern int flow;    /* Hardware handshaking Xon/Xoff=1, none=0 */
  566.     extern char turnch; /* Handshake character */
  567.     extern int parity;  /* Note that 8th-bit prefixing depends on this too */
  568.     
  569.     char * caps_port;
  570.  
  571.     /* Set the com ttname - capitalise first */
  572.     caps_port = strupr(ttname);
  573.     if(strcmp(caps_port,"COM1")==0)
  574.         WinSendDlgItemMsg(hwnd,DID_1COM,BM_SETCHECK,MPFROMSHORT(1),0L);
  575.     else if(strcmp(caps_port,"COM2")==0)
  576.         WinSendDlgItemMsg(hwnd,DID_2COM,BM_SETCHECK,MPFROMSHORT(1),0L);
  577.     else if(strcmp(caps_port,"COM3")==0)
  578.         WinSendDlgItemMsg(hwnd,DID_3COM,BM_SETCHECK,MPFROMSHORT(1),0L);
  579.  
  580.     /* Set the speed text */
  581.     WinSetDlgItemShort(hwnd,DID_BAUD,speed,FALSE);
  582.  
  583.     /* Set the parity */
  584.     switch(parity)
  585.         {
  586.         case 'e':
  587.             WinSendDlgItemMsg(hwnd,DID_EVEN,BM_SETCHECK,MPFROMSHORT(1),0L);
  588.             break;
  589.         case 'o':
  590.             WinSendDlgItemMsg(hwnd,DID_ODD,BM_SETCHECK,MPFROMSHORT(1),0L);
  591.             break;
  592.         case 'm':
  593.             WinSendDlgItemMsg(hwnd,DID_MARK,BM_SETCHECK,MPFROMSHORT(1),0L);
  594.             break;
  595.         case 's':
  596.             WinSendDlgItemMsg(hwnd,DID_SPACE,BM_SETCHECK,MPFROMSHORT(1),0L);
  597.             break;
  598.         case 0:
  599.             WinSendDlgItemMsg(hwnd,DID_NONE,BM_SETCHECK,MPFROMSHORT(1),0L);
  600.             break;
  601.         default:
  602.             break;
  603.         }
  604.  
  605.     /* The data bits */
  606.     
  607.     /* The stop bits */
  608.  
  609.     /* Hardware handshaking */
  610.     if( flow >0 )
  611.         WinSendDlgItemMsg(hwnd,DID_XHND,BM_SETCHECK,MPFROMSHORT(1),0L);
  612.     else
  613.         WinSendDlgItemMsg(hwnd,DID_HRDHND,BM_SETCHECK,MPFROMSHORT(1),0L);
  614.  
  615.     /* Hardware flow control */
  616.     WinSendDlgItemMsg(hwnd,DID_ODSR,BM_SETCHECK,
  617.             MPFROMSHORT( ((odsr>0 )?1:0) ),0L);
  618.     WinSendDlgItemMsg(hwnd,DID_IDSR,BM_SETCHECK,
  619.             MPFROMSHORT( ((idsr>0 )?1:0) ),0L);
  620.     WinSendDlgItemMsg(hwnd,DID_OCTS,BM_SETCHECK,
  621.             MPFROMSHORT( ((octs>0 )?1:0) ),0L);
  622.  
  623.     return(0);
  624.     }                                                       
  625.     
  626. int ComsDlgCmnd(HWND hwnd,int cmnd)
  627.     {
  628.     char buf[10];
  629.  
  630.     switch(cmnd)
  631.         {
  632.         case DID_IDSR:
  633.         case DID_OCTS:
  634.         case DID_ODSR:
  635.             if(WinSendDlgItemMsg(hwnd,cmnd,BM_QUERYCHECK,NULL,NULL)==0)
  636.                 WinSendDlgItemMsg(hwnd,cmnd,BM_SETCHECK,MPFROMSHORT(1),NULL);
  637.             else
  638.                 WinSendDlgItemMsg(hwnd,cmnd,BM_SETCHECK,NULL,NULL);
  639.             return(0);
  640.         default:     
  641.             break;
  642.         }
  643.     return(-1);
  644.     }
  645.  
  646.  
  647. /******************************************************************************
  648. Function:       MiscDlgProc()
  649.  
  650. Description:    Handles the miscellaneous parameters dialog.
  651.  
  652. Syntax:         MRESULT EXPENTRY MiscDlgProc(hwnd,msg,mp1,mp2)
  653.                     HWND hwnd       Standard details passed to a 
  654.                     USHORT msg      client procedure
  655.                     MPARAM mp1
  656.                     MPARAM mp2
  657.  
  658. Returns:        0 if message handled or result of WinDefDlgProc
  659.  
  660. Mods:           25-Apr-90 C.P.Armstrong created
  661.  
  662. ******************************************************************************/
  663. MRESULT EXPENTRY MiscDlgProc(HWND hwnd, USHORT msg, MPARAM mp1,MPARAM mp2)
  664.     {
  665.     switch(msg)
  666.         {
  667.         case WM_INITDLG:
  668.             MiscDlgInit(hwnd);
  669.             return(0);
  670.  
  671.         case WM_COMMAND:
  672.             switch(COMMANDMSG(&msg)->cmd)
  673.                 {
  674.                 case DID_EXIT:
  675.                     MiscDlgExit(hwnd);
  676.                 case DID_CANCEL:
  677.                     WinDismissDlg(hwnd,TRUE);
  678.                     return(0);
  679.                 default:
  680.                     break;
  681.                 }
  682.             break;
  683.         case WM_CONTROL:
  684.             if(MiscDlgCmnd(hwnd,SHORT1FROMMP(mp1))==0)
  685.                   return(0);
  686.             break;
  687.             
  688.         default:
  689.             break;
  690.         }
  691.     return(WinDefDlgProc(hwnd,msg,mp1,mp2));
  692.     }
  693.  
  694. int MiscDlgExit(HWND hwnd)
  695.     {
  696.     extern int paste_eol_char;
  697.  
  698.     WinQueryDlgItemShort(hwnd, DID_PEOL,(PSHORT)&paste_eol_char,FALSE);
  699.  
  700.     return(0);
  701.     }
  702.  
  703. int MiscDlgInit(HWND hwnd)
  704.     {
  705.     extern int paste_eol_char;
  706.  
  707.     /* Set the paste end of line character */
  708.     WinSetDlgItemShort(hwnd, DID_PEOL, (SHORT) paste_eol_char,FALSE);
  709.  
  710.     return(0);
  711.     }                                                       
  712.     
  713. int MiscDlgCmnd(HWND hwnd,int cmnd)
  714.     {
  715.     return(-1);
  716.     }
  717.     
  718.     
  719.