Category : C Source Code
Archive   : WINKERM.ZIP
Filename : KERMDEB.C

 
Output of file : KERMDEB.C contained in archive : WINKERM.ZIP
/*******************************************************************************
** **
** Kermit for Microsoft Windows **
** ---------------------------- **
** KERMDEB.C **
** **
** This module contains the debugging routines. **
** **
*******************************************************************************/

// INCLUDES -------------------------------------------------------------------

#include "kermit.h"

//-----------------------------------------------------------------------------
VOID WriteDebug(int nLevel, PSTR pszFmt, ...)

// Description of what function does.

// Param(s): x...............Description.

// Returns: Result description.

{
char sWork[128];
va_list pArg;
int nLen;

if (nLevel > DebugLevel)
return;

va_start(pArg, pszFmt);
nLen = vsprintf(sWork, pszFmt, pArg);
va_end(pArg);
sWork[nLen++] = '\n';
sWork[nLen] = '\0';

if (DebugStream == NULL)
MessageBeep(0);
if (DebugStream == stdout) {
if (hAppWnd)
MessageBox(hAppWnd, sWork, "Kermit", MB_OK | MB_ICONASTERISK);
else
MessageBox(GetActiveWindow(), sWork, "Kermit",
MB_OK | MB_ICONASTERISK);
}
else {
fputs(sWork, DebugStream);
fflush(DebugStream);
}
}

//-----------------------------------------------------------------------------
VOID DebugInit(HANDLE hInstance, HANDLE hPrevInstance,
LPSTR lpszCmdLine, int cmdShow)

// Description of what function does.

// Param(s): x...............Description.

// Returns: Result description.

{
char pszFileName[80];

DebugLevel = GetProfileInt("Kermit", "DebLevel", 0);

GetProfileString("Kermit", "DebDest", "", pszFileName,
sizeof(pszFileName));
if (strcmp(pszFileName, "POPUP") == 0)
DebugStream = stdout;
else
DebugStream = fopen(pszFileName, "w");

WriteDebug(4, "Kermit starting...");
WriteDebug(4, "hInstance=%u\nhPrevInstance=%u\n"
"lpszCmdLine=%Fs\ncmdShow=%i",
hInstance, hPrevInstance, lpszCmdLine, cmdShow);
}

//-----------------------------------------------------------------------------
VOID DebugTerm()

// Description of what function does.

// Param(s): x...............Description.

// Returns: Result description.

{
WriteDebug(4, "Kermit ending...");

if (DebugStream != stdout)
fclose(DebugStream);
}

//-----------------------------------------------------------------------------

VOID DebAssert(char *filename, int linenum, int exp, char *expstr)

// Description of what function does.

// Param(s): x...............Description.

// Returns: Result description.

{
if (exp)
return;

WriteDebug(1, "ASSERTION FAILED - File: %s, Line: %d\n%s",
filename, linenum, expstr);
}

//-----------------------------------------------------------------------------
VOID DebTrace(char *filename, int linenum, int nLevel, PSTR pszFmt, ...)

// Description of what function does.

// Param(s): x...............Description.

// Returns: Result description.

{
char sWork[128];
va_list pArg;
int nLen;

va_start(pArg, pszFmt);
nLen = vsprintf(sWork, pszFmt, pArg);
va_end(pArg);

WriteDebug(nLevel, "TRACE - File: %s, Line: %d\n%s",
filename, linenum, sWork);
}


  3 Responses to “Category : C Source Code
Archive   : WINKERM.ZIP
Filename : KERMDEB.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/