home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 15 / CDACTUAL15.iso / cdactual / program / c / WINKERM.ZIP / KERMINIT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-06-15  |  5.3 KB  |  144 lines

  1. /*******************************************************************************
  2. **                                                                            **
  3. **                      Kermit for Microsoft Windows                          **
  4. **                      ----------------------------                          **
  5. **                               KERMINIT.C                                   **
  6. **                                                                            **
  7. **  This module contains initialization functions required at application     **
  8. **  startup time.                                                             **
  9. **                                                                            **
  10. *******************************************************************************/
  11.  
  12. // INCLUDES -------------------------------------------------------------------
  13.  
  14. #include "kermit.h"
  15.  
  16. //-----------------------------------------------------------------------------
  17. BOOL NEAR MakeClass(HANDLE hInstance)
  18.  
  19. //  Description of what function does.
  20.  
  21. //  Param(s):   x...............Description.
  22.  
  23. //  Returns:    Result description.
  24.  
  25. {
  26.     WNDCLASS WndClass;
  27.      
  28.     WndClass.lpszClassName        = szAppName;
  29.     WndClass.hInstance            = hInstance;
  30.     WndClass.lpfnWndProc          = KermitWndProc;
  31.     WndClass.style                = NULL;
  32.     WndClass.hbrBackground        = (HBRUSH)GetStockObject(WHITE_BRUSH);
  33.     WndClass.hCursor              = LoadCursor(NULL, IDC_ARROW);
  34.     WndClass.hIcon                = LoadIcon(hInstance, "KermitIcon");
  35.     WndClass.lpszMenuName         = NULL;
  36.     WndClass.cbClsExtra           = NULL;
  37.     WndClass.cbWndExtra           = NULL;
  38.      
  39.     return(RegisterClass(&WndClass));
  40. }
  41.      
  42. //-----------------------------------------------------------------------------
  43. VOID NEAR ReadProfile(VOID)
  44.  
  45. //  Description of what function does.
  46.  
  47. //  Param(s):   x...............Description.
  48.  
  49. //  Returns:    Result description.
  50.  
  51. {
  52.     char szBuf [96];
  53.  
  54.     if (GetProfileString(szAppName, "Comm", COMMDEF, szBuf, sizeof(szBuf)))
  55.         sscanf(szBuf, "%u %u %u %u %u %u %u",
  56.                &CommSet.CommPort, &CommSet.BaudRate, &CommSet.DataBits,
  57.                &CommSet.Parity, &CommSet.StopBits, &CommSet.FlowControl,
  58.                &CommSet.HandShake);
  59.  
  60.     if (GetProfileString(szAppName, "Term", TERMDEF, szBuf, sizeof(szBuf)))
  61.         sscanf(szBuf, "%u %u %u %u %u",
  62.                &TermSet.Emulation, &TermSet.NewLine, &TermSet.LocalEcho,
  63.                &TermSet.LineWrap, &TermSet.TextSize);
  64.  
  65.     if (GetProfileString(szAppName, "Packets", PACKETDEF,
  66.                          szBuf, sizeof(szBuf)))
  67.         sscanf(szBuf, "%u %u %u %u %u %u %u %u %u %u",
  68.                &PktSet.Send.PadChar, &PktSet.Send.PadCount,
  69.                &PktSet.Send.StartChar, &PktSet.Send.EndChar,
  70.                &PktSet.Send.CtlPrefix, &PktSet.Recv.PadChar,
  71.                &PktSet.Recv.PadCount, &PktSet.Recv.StartChar,
  72.                &PktSet.Recv.EndChar, &PktSet.Recv.CtlPrefix);
  73.  
  74.     if (GetProfileString(szAppName, "Protocol", PROTOCOLDEF,
  75.                          szBuf, sizeof(szBuf)))
  76.         sscanf(szBuf, "%u %u %u %u %u %u %u %u %u %u %u %u",
  77.                &ProtSet.SendPktSize, &ProtSet.RecvPktSize,
  78.                &ProtSet.SendTimeout, &ProtSet.RecvTimeout,
  79.                &ProtSet.RetryLimit, &ProtSet.BlockCheck,
  80.                &ProtSet.DebugPacket, &ProtSet.DebugState,
  81.                &ProtSet.DebugOther, &ProtSet.Attributes,
  82.                &ProtSet.LongPackets, &ProtSet.Windowing);
  83.  
  84.     if (GetProfileString(szAppName, "SessionLog", SESLOGDEF,
  85.                          szBuf, sizeof(szBuf)))
  86.         sscanf(szBuf, "%u %s", &LogSet.SessionLogFlag, LogSet.SessionLogName);
  87.  
  88.     if (GetProfileString(szAppName, "PacketLog", PKTLOGDEF,
  89.                          szBuf, sizeof(szBuf)))
  90.         sscanf(szBuf, "%u %s", &LogSet.PacketLogFlag, LogSet.PacketLogName);
  91.  
  92.     if (GetProfileString(szAppName, "TransLog", TRNLOGDEF,
  93.                          szBuf, sizeof(szBuf)))
  94.         sscanf(szBuf, "%u %s", &LogSet.TransLogFlag, LogSet.TransLogName);
  95. }
  96.  
  97. //-----------------------------------------------------------------------------
  98. BOOL KermitInit(HANDLE hInstance, HANDLE hPrevInstance,
  99.                 LPSTR lpszCmdLine, int cmdShow)
  100.  
  101. //  Description of what function does.
  102.  
  103. //  Param(s):   x...............Description.
  104.  
  105. //  Returns:    Result description.
  106.  
  107. {
  108.     strcpy(szAppName, "Kermit");
  109.  
  110.     if (!hPrevInstance) {
  111.         if (!MakeClass(hInstance))
  112.         return(FALSE);
  113.     }
  114.      
  115.     ReadProfile();
  116.  
  117.     hAppInst = hInstance;
  118.     hAppWnd = CreateWindow(szAppName, szAppName,
  119.                            WS_OVERLAPPEDWINDOW,
  120.                            CW_USEDEFAULT,CW_USEDEFAULT,
  121.                            CW_USEDEFAULT,CW_USEDEFAULT,
  122.                            NULL,NULL,hInstance,NULL);
  123.  
  124.     hAppMenu = LoadMenu(hInstance, "KermitMenu");
  125.     SetMenu(hAppWnd, hAppMenu);
  126.  
  127.     hMenuAccel = LoadAccelerators(hInstance, "MenuAccel");
  128.     hXferAccel = LoadAccelerators(hInstance, "XferAccel");
  129.  
  130.     bConnected = FALSE;
  131.     EnableCommCommands(MF_GRAYED);
  132.  
  133.     bKermit = FALSE;
  134.     SetKermitCommands("StartMenu", MF_GRAYED);
  135.  
  136.     InitTerm();
  137.  
  138.     OpenTerm();
  139.     CloseTerm();
  140.  
  141.     ShowWindow(hAppWnd, cmdShow);
  142.     return(TRUE);
  143. }
  144.