Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
2.5 KiB

  1. // scraper.cpp : This file contains the
  2. // Created: Dec '97
  3. // History:
  4. // Copyright (C) 1997 Microsoft Corporation
  5. // All rights reserved.
  6. // Microsoft Confidential
  7. #include <CmnHdr.h>
  8. #include <TChar.h>
  9. #include <New.h>
  10. #include <Debug.h>
  11. #include <MsgFile.h>
  12. #include <TelnetD.h>
  13. #include <TlntUtils.h>
  14. #include <Session.h>
  15. #include <Resource.h>
  16. #include <LocResMan.h>
  17. #pragma warning( disable : 4100 )
  18. using namespace _Utils;
  19. using CDebugLevel::TRACE_DEBUGGING;
  20. using CDebugLevel::TRACE_HANDLE;
  21. using CDebugLevel::TRACE_SOCKET;
  22. HINSTANCE g_hInstRes = NULL;
  23. TCHAR g_szHeaderFormat[ MAX_STRING_LENGTH ];
  24. CSession *pClientSession = NULL;
  25. int __cdecl NoMoreMemory( size_t size )
  26. {
  27. int NO_MORE_MEMORY = 1;
  28. LogEvent( EVENTLOG_ERROR_TYPE, MSG_NOMOREMEMORY, _T(" ") );
  29. ExitProcess( 1 );
  30. _chASSERT(NO_MORE_MEMORY != 1);
  31. return 0;
  32. }
  33. void Init( )
  34. {
  35. #if _DEBUG || DBG
  36. CHAR szLogFileName[MAX_PATH];
  37. _snprintf( szLogFileName, (MAX_PATH-1), "c:\\temp\\scraper%d.log", GetCurrentThreadId() );
  38. CDebugLogger::Init( TRACE_DEBUGGING, szLogFileName );
  39. #endif
  40. HrLoadLocalizedLibrarySFU(NULL, L"TLNTSVRR.DLL", &g_hInstRes, NULL);
  41. LoadString(g_hInstRes, IDS_MESSAGE_HEADER, g_szHeaderFormat, MAX_STRING_LENGTH );
  42. }
  43. void Shutdown()
  44. {
  45. #if _DEBUG || DBG
  46. CDebugLogger::ShutDown();
  47. #endif
  48. }
  49. void
  50. LogEvent( WORD wType, DWORD dwEventID, LPCTSTR pFormat, ... )
  51. {
  52. LPCTSTR lpszStrings[1];
  53. lpszStrings[0] = pFormat;
  54. LogToTlntsvrLog( pClientSession->m_hLogHandle, wType, dwEventID,
  55. (LPCTSTR*) &lpszStrings[0] );
  56. return;
  57. }
  58. int __cdecl main()
  59. {
  60. // DebugBreak();
  61. SetErrorMode(SEM_FAILCRITICALERRORS |
  62. SEM_NOGPFAULTERRORBOX |
  63. SEM_NOALIGNMENTFAULTEXCEPT |
  64. SEM_NOOPENFILEERRORBOX
  65. );
  66. _set_new_handler( NoMoreMemory );
  67. Init( );
  68. pClientSession = new CSession;
  69. if( pClientSession )
  70. {
  71. __try
  72. {
  73. if( pClientSession->Init() )
  74. {
  75. _TRACE( TRACE_DEBUGGING, "new session ..." );
  76. pClientSession->WaitForIo();
  77. }
  78. }
  79. __finally
  80. {
  81. _TRACE( TRACE_DEBUGGING, "finally block ..." );
  82. pClientSession->Shutdown();
  83. delete pClientSession;
  84. }
  85. }
  86. Shutdown();
  87. return( 0 );
  88. }