home *** CD-ROM | disk | FTP | other *** search
- /*******************************************************************************
- ** **
- ** Kermit for Microsoft Windows **
- ** ---------------------------- **
- ** KERMINIT.C **
- ** **
- ** This module contains initialization functions required at application **
- ** startup time. **
- ** **
- *******************************************************************************/
-
- // INCLUDES -------------------------------------------------------------------
-
- #include "kermit.h"
-
- //-----------------------------------------------------------------------------
- BOOL NEAR MakeClass(HANDLE hInstance)
-
- // Description of what function does.
-
- // Param(s): x...............Description.
-
- // Returns: Result description.
-
- {
- WNDCLASS WndClass;
-
- WndClass.lpszClassName = szAppName;
- WndClass.hInstance = hInstance;
- WndClass.lpfnWndProc = KermitWndProc;
- WndClass.style = NULL;
- WndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
- WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
- WndClass.hIcon = LoadIcon(hInstance, "KermitIcon");
- WndClass.lpszMenuName = NULL;
- WndClass.cbClsExtra = NULL;
- WndClass.cbWndExtra = NULL;
-
- return(RegisterClass(&WndClass));
- }
-
- //-----------------------------------------------------------------------------
- VOID NEAR ReadProfile(VOID)
-
- // Description of what function does.
-
- // Param(s): x...............Description.
-
- // Returns: Result description.
-
- {
- char szBuf [96];
-
- if (GetProfileString(szAppName, "Comm", COMMDEF, szBuf, sizeof(szBuf)))
- sscanf(szBuf, "%u %u %u %u %u %u %u",
- &CommSet.CommPort, &CommSet.BaudRate, &CommSet.DataBits,
- &CommSet.Parity, &CommSet.StopBits, &CommSet.FlowControl,
- &CommSet.HandShake);
-
- if (GetProfileString(szAppName, "Term", TERMDEF, szBuf, sizeof(szBuf)))
- sscanf(szBuf, "%u %u %u %u %u",
- &TermSet.Emulation, &TermSet.NewLine, &TermSet.LocalEcho,
- &TermSet.LineWrap, &TermSet.TextSize);
-
- if (GetProfileString(szAppName, "Packets", PACKETDEF,
- szBuf, sizeof(szBuf)))
- sscanf(szBuf, "%u %u %u %u %u %u %u %u %u %u",
- &PktSet.Send.PadChar, &PktSet.Send.PadCount,
- &PktSet.Send.StartChar, &PktSet.Send.EndChar,
- &PktSet.Send.CtlPrefix, &PktSet.Recv.PadChar,
- &PktSet.Recv.PadCount, &PktSet.Recv.StartChar,
- &PktSet.Recv.EndChar, &PktSet.Recv.CtlPrefix);
-
- if (GetProfileString(szAppName, "Protocol", PROTOCOLDEF,
- szBuf, sizeof(szBuf)))
- sscanf(szBuf, "%u %u %u %u %u %u %u %u %u %u %u %u",
- &ProtSet.SendPktSize, &ProtSet.RecvPktSize,
- &ProtSet.SendTimeout, &ProtSet.RecvTimeout,
- &ProtSet.RetryLimit, &ProtSet.BlockCheck,
- &ProtSet.DebugPacket, &ProtSet.DebugState,
- &ProtSet.DebugOther, &ProtSet.Attributes,
- &ProtSet.LongPackets, &ProtSet.Windowing);
-
- if (GetProfileString(szAppName, "SessionLog", SESLOGDEF,
- szBuf, sizeof(szBuf)))
- sscanf(szBuf, "%u %s", &LogSet.SessionLogFlag, LogSet.SessionLogName);
-
- if (GetProfileString(szAppName, "PacketLog", PKTLOGDEF,
- szBuf, sizeof(szBuf)))
- sscanf(szBuf, "%u %s", &LogSet.PacketLogFlag, LogSet.PacketLogName);
-
- if (GetProfileString(szAppName, "TransLog", TRNLOGDEF,
- szBuf, sizeof(szBuf)))
- sscanf(szBuf, "%u %s", &LogSet.TransLogFlag, LogSet.TransLogName);
- }
-
- //-----------------------------------------------------------------------------
- BOOL KermitInit(HANDLE hInstance, HANDLE hPrevInstance,
- LPSTR lpszCmdLine, int cmdShow)
-
- // Description of what function does.
-
- // Param(s): x...............Description.
-
- // Returns: Result description.
-
- {
- strcpy(szAppName, "Kermit");
-
- if (!hPrevInstance) {
- if (!MakeClass(hInstance))
- return(FALSE);
- }
-
- ReadProfile();
-
- hAppInst = hInstance;
- hAppWnd = CreateWindow(szAppName, szAppName,
- WS_OVERLAPPEDWINDOW,
- CW_USEDEFAULT,CW_USEDEFAULT,
- CW_USEDEFAULT,CW_USEDEFAULT,
- NULL,NULL,hInstance,NULL);
-
- hAppMenu = LoadMenu(hInstance, "KermitMenu");
- SetMenu(hAppWnd, hAppMenu);
-
- hMenuAccel = LoadAccelerators(hInstance, "MenuAccel");
- hXferAccel = LoadAccelerators(hInstance, "XferAccel");
-
- bConnected = FALSE;
- EnableCommCommands(MF_GRAYED);
-
- bKermit = FALSE;
- SetKermitCommands("StartMenu", MF_GRAYED);
-
- InitTerm();
-
- OpenTerm();
- CloseTerm();
-
- ShowWindow(hAppWnd, cmdShow);
- return(TRUE);
- }
-