Append .dll extension in all cases (spotted by Mike Hearn).
[wine/wine-kai.git] / dlls / advapi32 / eventlog.c
blobee7f9652fbd106cc7299a4018b3da850c701b297
1 /*
2 * Win32 advapi functions
4 * Copyright 1995 Sven Verdoolaege
5 * Copyright 1998 Juergen Schmied
6 * Copyright 2003 Mike Hearn
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include <stdarg.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winerror.h"
28 #include "winreg.h"
29 #include "winternl.h"
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(advapi);
34 WINE_DECLARE_DEBUG_CHANNEL(eventlog);
36 /******************************************************************************
37 * BackupEventLogA [ADVAPI32.@]
39 * Saves the event log to a backup file.
41 * PARAMS
42 * hEventLog [I] Handle to event log to backup.
43 * lpBackupFileName [I] Name of the backup file.
45 * RETURNS
46 * Success: nonzero. File lpBackupFileName will contain the contents of
47 * hEvenLog.
48 * Failure: zero.
50 BOOL WINAPI BackupEventLogA( HANDLE hEventLog, LPCSTR lpBackupFileName )
52 FIXME("stub\n");
53 return TRUE;
56 /******************************************************************************
57 * BackupEventLogW [ADVAPI32.@]
59 * see BackupEventLogA
61 BOOL WINAPI
62 BackupEventLogW( HANDLE hEventLog, LPCWSTR lpBackupFileName )
64 FIXME("stub\n");
65 return TRUE;
68 /******************************************************************************
69 * ClearEventLogA [ADVAPI32.@]
71 * Clears the event log and/or saves the log to a backup file.
73 * PARAMS
74 * hEvenLog [I] Handle to event log to clear.
75 * lpBackupFileName [I] Name of the backup file.
77 * RETURNS
78 * Success: nonzero. if lpBackupFileName != NULL, lpBackupFileName will
79 * contain the contents of hEvenLog and the log will be cleared.
80 * Failure: zero. Fails if the event log is empty or if lpBackupFileName
81 * exists.
83 BOOL WINAPI ClearEventLogA ( HANDLE hEventLog, LPCSTR lpBackupFileName )
85 FIXME("stub\n");
86 return TRUE;
89 /******************************************************************************
90 * ClearEventLogW [ADVAPI32.@]
92 * see ClearEventLogA
94 BOOL WINAPI ClearEventLogW ( HANDLE hEventLog, LPCWSTR lpBackupFileName )
96 FIXME("stub\n");
97 return TRUE;
100 /******************************************************************************
101 * CloseEventLog [ADVAPI32.@]
103 * Closes a read handle to the event log.
105 * PARAMS
106 * hEventLog [I/O] Handle of the event log to close.
108 * RETURNS
109 * Success: nonzero
110 * Failure: zero
112 BOOL WINAPI CloseEventLog ( HANDLE hEventLog )
114 FIXME("stub\n");
115 return TRUE;
118 /******************************************************************************
119 * DeregisterEventSource [ADVAPI32.@]
121 * Closes a write handle to an event log
123 * PARAMS
124 * hEventLog [I/O] Handle of the event log.
126 * RETURNS
127 * Success: nonzero
128 * Failure: zero
130 BOOL WINAPI DeregisterEventSource( HANDLE hEventLog )
132 FIXME("(%p): stub\n",hEventLog);
133 return TRUE;
136 /******************************************************************************
137 * GetNumberOfEventLogRecords [ADVAPI32.@]
139 * Retrieves the number of records in an event log.
141 * PARAMS
142 * hEventLog [I] Handle to an open event log.
143 * NumberOfRecords [O] Number of records in the log.
145 * RETURNS
146 * Success: nonzero. NumberOfRecords will contain the number of records in
147 * the log.
148 * Failure: zero
150 BOOL WINAPI
151 GetNumberOfEventLogRecords( HANDLE hEventLog, PDWORD NumberOfRecords )
153 FIXME("stub\n");
154 return TRUE;
157 /******************************************************************************
158 * GetOldestEventLogRecord [ADVAPI32.@]
160 * Retrieves the absolute record number of the oldest record in an even log.
162 * PARAMS
163 * hEventLog [I] Handle to an open event log.
164 * OldestRecord [O] Absolute record number of the oldest record.
166 * RETURNS
167 * Success: nonzero. OldestRecord contains the record number of the oldest
168 * record in the log.
169 * Failure: zero
171 BOOL WINAPI
172 GetOldestEventLogRecord( HANDLE hEventLog, PDWORD OldestRecord )
174 FIXME(":stub\n");
175 return TRUE;
178 /******************************************************************************
179 * NotifyChangeEventLog [ADVAPI32.@]
181 * Enables an application to receive notification when an event is written
182 * to an event log.
184 * PARAMS
185 * hEventLog [I] Handle to an event log.
186 * hEvent [I] Handle to a manual-reset event object.
188 * RETURNS
189 * Success: nonzero
190 * Failure: zero
192 BOOL WINAPI NotifyChangeEventLog( HANDLE hEventLog, HANDLE hEvent )
194 FIXME("stub\n");
195 return TRUE;
198 /******************************************************************************
199 * OpenBackupEventLogA [ADVAPI32.@]
201 * Opens a handle to a backup event log.
203 * PARAMS
204 * lpUNCServerName [I] Universal Naming Convention name of the server on which
205 * this will be performed.
206 * lpFileName [I] Specifies the name of the backup file.
208 * RETURNS
209 * Success: Handle to the backup event log.
210 * Failure: NULL
212 HANDLE WINAPI
213 OpenBackupEventLogA( LPCSTR lpUNCServerName, LPCSTR lpFileName )
215 FIXME("stub\n");
216 return (HANDLE)1;
219 /******************************************************************************
220 * OpenBackupEventLogW [ADVAPI32.@]
222 * see OpenBackupEventLogA
224 HANDLE WINAPI
225 OpenBackupEventLogW( LPCWSTR lpUNCServerName, LPCWSTR lpFileName )
227 FIXME("stub\n");
228 return (HANDLE)1;
231 /******************************************************************************
232 * OpenEventLogA [ADVAPI32.@]
234 * Opens a handle to the specified event log.
236 * PARAMS
237 * lpUNCServerName [I] UNC name of the server on which the event log is
238 * opened.
239 * lpSourceName [I] Name of the log.
241 * RETURNS
242 * Success: Handle to an event log.
243 * Failure: NULL
245 HANDLE WINAPI OpenEventLogA(LPCSTR uncname,LPCSTR source)
247 FIXME("(%s,%s),stub!\n",uncname,source);
248 return (HANDLE)0xcafe4242;
251 /******************************************************************************
252 * OpenEventLogW [ADVAPI32.@]
254 * see OpenEventLogA
256 HANDLE WINAPI
257 OpenEventLogW( LPCWSTR uncname, LPCWSTR source )
259 FIXME("stub\n");
260 return (HANDLE)1;
263 /******************************************************************************
264 * ReadEventLogA [ADVAPI32.@]
266 * Reads a whole number of entries from an event log.
268 * PARAMS
269 * hEventLog [I] Handle of the event log to read.
270 * dwReadFlags [I] see MSDN doc.
271 * dwRecordOffset [I] Log-entry record number to start at.
272 * lpBuffer [O] Buffer for the data read.
273 * nNumberOfBytesToRead [I] Size of lpBuffer.
274 * pnBytesRead [O] Receives number of bytes read.
275 * pnMinNumberOfBytesNeeded [O] Receives number of bytes required for the
276 * next log entry.
278 * RETURNS
279 * Success: nonzero
280 * Failure: zero
282 BOOL WINAPI ReadEventLogA( HANDLE hEventLog, DWORD dwReadFlags, DWORD dwRecordOffset,
283 LPVOID lpBuffer, DWORD nNumberOfBytesToRead, DWORD *pnBytesRead, DWORD *pnMinNumberOfBytesNeeded )
285 FIXME("stub\n");
286 return TRUE;
289 /******************************************************************************
290 * ReadEventLogW [ADVAPI32.@]
292 * see ReadEventLogA
294 BOOL WINAPI
295 ReadEventLogW( HANDLE hEventLog, DWORD dwReadFlags, DWORD dwRecordOffset,
296 LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
297 DWORD *pnBytesRead, DWORD *pnMinNumberOfBytesNeeded )
299 FIXME("stub\n");
300 return TRUE;
303 /******************************************************************************
304 * RegisterEventSourceA [ADVAPI32.@]
306 * Returns a registered handle to an event log.
308 * PARAMS
309 * lpUNCServerName [I] UNC name of the source server.
310 * lpSourceName [I] Specifies the name of the event source to retrieve.
312 * RETURNS
313 * Success: Handle to the event log.
314 * Failure: NULL. Returns ERROR_INVALID_HANDLE if lpSourceName specifies the
315 * Security event log.
317 HANDLE WINAPI RegisterEventSourceA( LPCSTR lpUNCServerName, LPCSTR lpSourceName )
320 UNICODE_STRING lpUNCServerNameW;
321 UNICODE_STRING lpSourceNameW;
322 HANDLE ret;
323 RtlCreateUnicodeStringFromAsciiz(&lpUNCServerNameW, lpUNCServerName);
324 RtlCreateUnicodeStringFromAsciiz(&lpSourceNameW, lpSourceName);
325 ret = RegisterEventSourceW(lpUNCServerNameW.Buffer,lpSourceNameW.Buffer);
326 RtlFreeUnicodeString (&lpUNCServerNameW);
327 RtlFreeUnicodeString (&lpSourceNameW);
328 return ret;
331 /******************************************************************************
332 * RegisterEventSourceW [ADVAPI32.@]
334 * see RegisterEventSourceA
336 HANDLE WINAPI
337 RegisterEventSourceW( LPCWSTR lpUNCServerName, LPCWSTR lpSourceName )
339 FIXME("(%s,%s): stub\n", debugstr_w(lpUNCServerName),
340 debugstr_w(lpSourceName));
341 return (HANDLE)1;
344 /******************************************************************************
345 * ReportEventA [ADVAPI32.@]
347 * Writes an entry at the end of an event log.
349 * PARAMS
350 * hEventLog [I] Handle of an event log.
351 * wType [I] See MSDN doc.
352 * wCategory [I] Event category.
353 * dwEventID [I] Event identifier.
354 * lpUserSid [I] Current user's security identifier.
355 * wNumStrings [I] Number of insert strings in lpStrings.
356 * dwDataSize [I] Size of event-specific raw data to write.
357 * lpStrings [I] Buffer containing an array of string to be merged.
358 * lpRawData [I] Buffer containing the binary data.
360 * RETURNS
361 * Success: nonzero. Entry was written to the log.
362 * Failure: zero.
364 * NOTES
365 * The ReportEvent function adds the time, the entry's length, and the
366 * offsets before storing the entry in the log. If lpUserSid != NULL, the
367 * username is also logged.
369 BOOL WINAPI ReportEventA ( HANDLE hEventLog, WORD wType, WORD wCategory, DWORD dwEventID,
370 PSID lpUserSid, WORD wNumStrings, DWORD dwDataSize, LPCSTR *lpStrings, LPVOID lpRawData)
372 LPCWSTR *wideStrArray;
373 UNICODE_STRING str;
374 int i;
375 BOOL ret;
377 if (wNumStrings == 0) return TRUE;
378 if (!lpStrings) return TRUE;
380 wideStrArray = HeapAlloc(GetProcessHeap(), 0, sizeof(LPCWSTR) * wNumStrings);
381 for (i = 0; i < wNumStrings; i++)
383 RtlCreateUnicodeStringFromAsciiz(&str, lpStrings[i]);
384 wideStrArray[i] = str.Buffer;
386 ret = ReportEventW(hEventLog, wType, wCategory, dwEventID, lpUserSid,
387 wNumStrings, dwDataSize, wideStrArray, lpRawData);
388 for (i = 0; i < wNumStrings; i++)
390 if (wideStrArray[i]) HeapFree( GetProcessHeap(), 0, (LPSTR)wideStrArray[i] );
392 HeapFree(GetProcessHeap(), 0, wideStrArray);
393 return ret;
396 /******************************************************************************
397 * ReportEventW [ADVAPI32.@]
399 * see ReportEventA
401 BOOL WINAPI
402 ReportEventW( HANDLE hEventLog, WORD wType, WORD wCategory,
403 DWORD dwEventID, PSID lpUserSid, WORD wNumStrings,
404 DWORD dwDataSize, LPCWSTR *lpStrings, LPVOID lpRawData )
406 int i;
408 /* partial stub */
410 if (wNumStrings == 0) return TRUE;
411 if (!lpStrings) return TRUE;
413 for (i = 0; i < wNumStrings; i++)
415 switch (wType)
417 case EVENTLOG_SUCCESS:
418 TRACE_(eventlog)("%s\n", debugstr_w(lpStrings[i]));
419 break;
420 case EVENTLOG_ERROR_TYPE:
421 ERR_(eventlog)("%s\n", debugstr_w(lpStrings[i]));
422 break;
423 case EVENTLOG_WARNING_TYPE:
424 WARN_(eventlog)("%s\n", debugstr_w(lpStrings[i]));
425 break;
426 default:
427 TRACE_(eventlog)("%s\n", debugstr_w(lpStrings[i]));
428 break;
431 return TRUE;