[CMAKE]
[reactos.git] / dll / win32 / samlib / dllmain.c
1 /*
2 * ReactOS kernel
3 * Copyright (C) 2004 ReactOS Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19 /* $Id$
20 *
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS system libraries
23 * PURPOSE: SAM interface library
24 * FILE: lib/samlib/dllmain.c
25 * PROGRAMER: Eric Kohl
26 */
27
28 /* INCLUDES *****************************************************************/
29
30 #include <stdio.h>
31 #include <stdarg.h>
32
33 #include <windef.h>
34 #include <winbase.h>
35
36 #include "debug.h"
37
38 //#define LOG_DEBUG_MESSAGES
39
40 /* GLOBALS *******************************************************************/
41
42
43 /* FUNCTIONS *****************************************************************/
44
45 BOOL WINAPI
46 DllMain (HINSTANCE hInstance,
47 DWORD dwReason,
48 LPVOID lpReserved)
49 {
50
51 return TRUE;
52 }
53
54
55 void
56 DebugPrint (char* fmt,...)
57 {
58 #ifdef LOG_DEBUG_MESSAGES
59 char FileName[MAX_PATH];
60 HANDLE hLogFile;
61 DWORD dwBytesWritten;
62 #endif
63 char buffer[512];
64 va_list ap;
65
66 va_start (ap, fmt);
67 vsprintf (buffer, fmt, ap);
68 va_end (ap);
69
70 OutputDebugStringA (buffer);
71
72 #ifdef LOG_DEBUG_MESSAGES
73 strcpy (FileName, "C:\\reactos\\samlib.log");
74 hLogFile = CreateFileA (FileName,
75 GENERIC_WRITE,
76 0,
77 NULL,
78 OPEN_ALWAYS,
79 FILE_ATTRIBUTE_NORMAL,
80 NULL);
81 if (hLogFile == INVALID_HANDLE_VALUE)
82 return;
83
84 if (SetFilePointer(hLogFile, 0, NULL, FILE_END) == 0xFFFFFFFF)
85 {
86 CloseHandle (hLogFile);
87 return;
88 }
89
90 WriteFile (hLogFile,
91 buffer,
92 strlen(buffer),
93 &dwBytesWritten,
94 NULL);
95
96 CloseHandle (hLogFile);
97 #endif
98 }
99
100 /* EOF */