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.

94 lines
2.4 KiB

  1. //-------------------------------------------------------------------------
  2. //
  3. // Microsoft OLE
  4. // Copyright (C) Microsoft Corporation, 1994 - 1995.
  5. //
  6. // File: dllinit.cxx
  7. //
  8. // Contents: OLE storage base tests
  9. //
  10. // Functions: dllinit
  11. // RunTests
  12. //
  13. // History: 22-Jan-1998 SCousens Created.
  14. //
  15. //--------------------------------------------------------------------------
  16. #include <dfheader.hxx>
  17. #pragma hdrstop
  18. #include "init.hxx"
  19. extern int __cdecl main(int argc, char *argv[]);
  20. #define STGBASE_INI "stgbase.ini"
  21. HINSTANCE ghinstDll;
  22. __declspec(dllexport) BOOL WINAPI DllMain(
  23. HINSTANCE hinstDLL,
  24. DWORD fdwReason,
  25. LPVOID lpvReserved)
  26. {
  27. if(fdwReason == DLL_PROCESS_ATTACH)
  28. {
  29. ghinstDll = hinstDLL;
  30. }
  31. return TRUE;
  32. }
  33. // read all the commandlines in from a .ini file and call main with them.
  34. extern "C" __declspec(dllexport) void RunTest (void)
  35. {
  36. HRESULT hr;
  37. FILE* fp;
  38. CHAR szLine[2048];
  39. int count;
  40. int argc;
  41. char **argv;
  42. DH_FUNCENTRY (&hr, DH_LVL_TRACE1, TEXT("RunTests"));
  43. //Open the .ini file
  44. if (NULL == (fp = fopen (STGBASE_INI, "r")))
  45. {
  46. DH_TRACE ((DH_LVL_ERROR,
  47. TEXT("Error opening stgbase.ini Err=%ld"),
  48. GetLastError ()));
  49. MessageBox (NULL,
  50. TEXT("Error Occured while opening stgbase.ini"),
  51. TEXT("Sandbox Test"),
  52. MB_ICONERROR | MB_ICONSTOP);
  53. return;
  54. }
  55. // read a line
  56. while (fgets (szLine, sizeof(szLine), fp) != NULL)
  57. {
  58. // safety check - if 1st char is alphanum assume ok.
  59. if (*szLine >= 'A' && *szLine <= 'Z' ||
  60. *szLine >= 'a' && *szLine <= 'z' ||
  61. *szLine >= '1' && *szLine <= '0')
  62. {
  63. // convert to argc argv and call main
  64. hr = CmdlineToArgs (szLine, &argc, &argv);
  65. DH_HRCHECK (hr, TEXT("CmdlineToArgs"));
  66. if (S_OK == hr)
  67. {
  68. hr = main (argc, argv);
  69. DH_HRCHECK (hr, TEXT("Call to Stgbase::main"));
  70. }
  71. // cleanup for arguments strings
  72. if (NULL != argv)
  73. {
  74. for (count=0; count<argc; count++)
  75. delete argv[count];
  76. delete [] argv;
  77. }
  78. }
  79. }
  80. fclose (fp);
  81. }