2 * Unix SMB/CIFS implementation.
3 * Virtual Windows Registry Layer
4 * Copyright (C) Marcin Krzysztof Porwit 2005,
5 * Copyright (C) Brian Moran 2005.
6 * Copyright (C) Gerald (Jerry) Carter 2005.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program 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
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 /**********************************************************************
27 for an eventlog, add in the default values
28 *********************************************************************/
30 BOOL
eventlog_init_keys( void )
32 /* Find all of the eventlogs, add keys for each of them */
33 const char **elogs
= lp_eventlog_list( );
35 REGSUBKEY_CTR
*subkeys
;
37 uint32 uiDisplayNameId
;
40 uint32 uiCategoryCount
;
43 while ( elogs
&& *elogs
) {
44 if ( !( subkeys
= TALLOC_ZERO_P( NULL
, REGSUBKEY_CTR
) ) ) {
45 DEBUG( 0, ( "talloc() failure!\n" ) );
48 regdb_fetch_keys( KEY_EVENTLOG
, subkeys
);
49 regsubkey_ctr_addkey( subkeys
, *elogs
);
50 if ( !regdb_store_keys( KEY_EVENTLOG
, subkeys
) )
52 TALLOC_FREE( subkeys
);
54 /* add in the key of form KEY_EVENTLOG/Application */
56 ( "Adding key of [%s] to path of [%s]\n", *elogs
,
59 slprintf( evtlogpath
, sizeof( evtlogpath
) - 1, "%s\\%s",
60 KEY_EVENTLOG
, *elogs
);
61 /* add in the key of form KEY_EVENTLOG/Application/Application */
63 ( "Adding key of [%s] to path of [%s]\n", *elogs
,
65 if ( !( subkeys
= TALLOC_ZERO_P( NULL
, REGSUBKEY_CTR
) ) ) {
66 DEBUG( 0, ( "talloc() failure!\n" ) );
69 regdb_fetch_keys( evtlogpath
, subkeys
);
70 regsubkey_ctr_addkey( subkeys
, *elogs
);
72 if ( !regdb_store_keys( evtlogpath
, subkeys
) )
74 TALLOC_FREE( subkeys
);
76 /* now add the values to the KEY_EVENTLOG/Application form key */
77 if ( !( values
= TALLOC_ZERO_P( NULL
, REGVAL_CTR
) ) ) {
78 DEBUG( 0, ( "talloc() failure!\n" ) );
82 ( "Storing values to eventlog path of [%s]\n",
84 regdb_fetch_values( evtlogpath
, values
);
86 if ( !regval_ctr_key_exists( values
, "MaxSize" ) ) {
87 /* assume we have none, add them all */
89 /* hard code some initial values */
91 uiDisplayNameId
= 0x00000100;
92 uiMaxSize
= 0x00080000;
93 uiRetention
= 0x93A80;
95 regval_ctr_addvalue( values
, "MaxSize", REG_DWORD
,
96 ( char * ) &uiMaxSize
,
98 regval_ctr_addvalue( values
, "Retention", REG_DWORD
,
99 ( char * ) &uiRetention
,
101 init_unistr2( &data
, *elogs
, UNI_STR_TERMINATE
);
102 regval_ctr_addvalue( values
, "PrimaryModule", REG_SZ
,
103 ( char * ) data
.buffer
,
106 init_unistr2( &data
, *elogs
, UNI_STR_TERMINATE
);
108 regval_ctr_addvalue( values
, "Sources", REG_MULTI_SZ
,
109 ( char * ) data
.buffer
,
112 regdb_store_values( evtlogpath
, values
);
116 TALLOC_FREE( values
);
118 /* now do the values under KEY_EVENTLOG/Application/Application */
119 slprintf( evtlogpath
, sizeof( evtlogpath
) - 1, "%s\\%s\\%s",
120 KEY_EVENTLOG
, *elogs
, *elogs
);
121 if ( !( values
= TALLOC_ZERO_P( NULL
, REGVAL_CTR
) ) ) {
122 DEBUG( 0, ( "talloc() failure!\n" ) );
126 ( "Storing values to eventlog path of [%s]\n",
128 regdb_fetch_values( evtlogpath
, values
);
129 if ( !regval_ctr_key_exists( values
, "CategoryCount" ) ) {
131 /* hard code some initial values */
133 uiCategoryCount
= 0x00000007;
134 regval_ctr_addvalue( values
, "CategoryCount",
136 ( char * ) &uiCategoryCount
,
139 "%SystemRoot%\\system32\\eventlog.dll",
142 regval_ctr_addvalue( values
, "CategoryMessageFile",
144 ( char * ) data
.buffer
,
147 regdb_store_values( evtlogpath
, values
);
149 TALLOC_FREE( values
);