Author: jerry Date: 2005-10-10 22:05:06 +0000 (Mon, 10 Oct 2005) New Revision: 10882
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=10882 Log: renames for #defines of event lgo tdb keys (for consistency) & fix wr_eventlog for new elog_open_tdb() semantics Modified: trunk/source/include/rpc_eventlog.h trunk/source/rpc_server/srv_eventlog_lib.c trunk/source/rpc_server/srv_eventlog_nt.c trunk/source/utils/wr_eventlog.c Changeset: Modified: trunk/source/include/rpc_eventlog.h =================================================================== --- trunk/source/include/rpc_eventlog.h 2005-10-10 21:44:01 UTC (rev 10881) +++ trunk/source/include/rpc_eventlog.h 2005-10-10 22:05:06 UTC (rev 10882) @@ -47,11 +47,11 @@ #define EVENTLOG_AUDIT_FAILURE 0x0010 /* Defines for TDB keys */ -#define VN_oldest_entry "INFO/oldest_entry" -#define VN_next_record "INFO/next_record" -#define VN_version "INFO/version" -#define VN_maxsize "INFO/maxsize" -#define VN_retention "INFO/retention" +#define EVT_OLDEST_ENTRY "INFO/oldest_entry" +#define EVT_NEXT_RECORD "INFO/next_record" +#define EVT_VERSION "INFO/version" +#define EVT_MAXSIZE "INFO/maxsize" +#define EVT_RETENTION "INFO/retention" #define ELOG_APPL "Application" #define ELOG_SYS "System" Modified: trunk/source/rpc_server/srv_eventlog_lib.c =================================================================== --- trunk/source/rpc_server/srv_eventlog_lib.c 2005-10-10 21:44:01 UTC (rev 10881) +++ trunk/source/rpc_server/srv_eventlog_lib.c 2005-10-10 22:05:06 UTC (rev 10882) @@ -55,12 +55,12 @@ /* initialize with defaults, copy real values in here from registry */ - tdb_store_int32( tdb, VN_oldest_entry, 1 ); - tdb_store_int32( tdb, VN_next_record, 1 ); - tdb_store_int32( tdb, VN_maxsize, 0x80000 ); - tdb_store_int32( tdb, VN_retention, 0x93A80 ); + tdb_store_int32( tdb, EVT_OLDEST_ENTRY, 1 ); + tdb_store_int32( tdb, EVT_NEXT_RECORD, 1 ); + tdb_store_int32( tdb, EVT_MAXSIZE, 0x80000 ); + tdb_store_int32( tdb, EVT_RETENTION, 0x93A80 ); - tdb_store_int32( tdb, VN_version, EVENTLOG_DATABASE_VERSION_V1 ); + tdb_store_int32( tdb, EVT_VERSION, EVENTLOG_DATABASE_VERSION_V1 ); return tdb; } @@ -120,11 +120,11 @@ tdb_traverse( tdb, eventlog_tdb_size_fn, &tsize ); if ( MaxSize != NULL ) { - *MaxSize = tdb_fetch_int32( tdb, VN_maxsize ); + *MaxSize = tdb_fetch_int32( tdb, EVT_MAXSIZE ); } if ( Retention != NULL ) { - *Retention = tdb_fetch_int32( tdb, VN_retention ); + *Retention = tdb_fetch_int32( tdb, EVT_RETENTION ); } DEBUG( 1, @@ -168,12 +168,12 @@ if ( mem_ctx == NULL ) return False; /* can't allocate memory indicates bigger problems */ /* lock */ - tdb_lock_bystring( the_tdb, VN_next_record, 1 ); + tdb_lock_bystring( the_tdb, EVT_NEXT_RECORD, 1 ); /* read */ - end_record = tdb_fetch_int32( the_tdb, VN_next_record ); - start_record = tdb_fetch_int32( the_tdb, VN_oldest_entry ); - Retention = tdb_fetch_int32( the_tdb, VN_retention ); - MaxSize = tdb_fetch_int32( the_tdb, VN_maxsize ); + end_record = tdb_fetch_int32( the_tdb, EVT_NEXT_RECORD ); + start_record = tdb_fetch_int32( the_tdb, EVT_OLDEST_ENTRY ); + Retention = tdb_fetch_int32( the_tdb, EVT_RETENTION ); + MaxSize = tdb_fetch_int32( the_tdb, EVT_MAXSIZE ); time( ¤t_time ); @@ -199,7 +199,7 @@ DEBUG( 8, ( "Can't find a record for the key, record [%d]\n", i ) ); - tdb_unlock_bystring( the_tdb, VN_next_record ); + tdb_unlock_bystring( the_tdb, EVT_NEXT_RECORD ); return False; } nbytes += ret.dsize; /* note this includes overhead */ @@ -236,9 +236,9 @@ tdb_delete( the_tdb, key ); } - tdb_store_int32( the_tdb, VN_oldest_entry, new_start ); + tdb_store_int32( the_tdb, EVT_OLDEST_ENTRY, new_start ); } - tdb_unlock_bystring( the_tdb, VN_next_record ); + tdb_unlock_bystring( the_tdb, EVT_NEXT_RECORD ); return True; } @@ -340,7 +340,7 @@ tdb = tdb_open_log( tdbpath, 0, TDB_DEFAULT, O_RDWR , 0 ); if ( tdb ) { - vers_id = tdb_fetch_int32( tdb, VN_version ); + vers_id = tdb_fetch_int32( tdb, EVT_VERSION ); if ( vers_id != EVENTLOG_DATABASE_VERSION_V1 ) { DEBUG(1,("elog_open_tdb: Invalid version [%d] on file [%s].\n", @@ -466,9 +466,9 @@ /* need to read the record number and insert it into the entry here */ /* lock */ - tdb_lock_bystring( the_tdb, VN_next_record, 1 ); + tdb_lock_bystring( the_tdb, EVT_NEXT_RECORD, 1 ); /* read */ - next_record = tdb_fetch_int32( the_tdb, VN_next_record ); + next_record = tdb_fetch_int32( the_tdb, EVT_NEXT_RECORD ); n_packed = tdb_pack( packed_ee, ee->record.length + MARGIN, @@ -507,13 +507,13 @@ if ( tdb_store( the_tdb, kbuf, ebuf, 0 ) ) { /* DEBUG(1,("write_eventlog_tdb: Can't write record %d to eventlog\n",next_record)); */ - tdb_unlock_bystring( the_tdb, VN_next_record ); + tdb_unlock_bystring( the_tdb, EVT_NEXT_RECORD ); talloc_destroy( mem_ctx ); return 0; } next_record++; - tdb_store_int32( the_tdb, VN_next_record, next_record ); - tdb_unlock_bystring( the_tdb, VN_next_record ); + tdb_store_int32( the_tdb, EVT_NEXT_RECORD, next_record ); + tdb_unlock_bystring( the_tdb, EVT_NEXT_RECORD ); talloc_destroy( mem_ctx ); return ( next_record - 1 ); } Modified: trunk/source/rpc_server/srv_eventlog_nt.c =================================================================== --- trunk/source/rpc_server/srv_eventlog_nt.c 2005-10-10 21:44:01 UTC (rev 10881) +++ trunk/source/rpc_server/srv_eventlog_nt.c 2005-10-10 22:05:06 UTC (rev 10882) @@ -326,8 +326,8 @@ regkey_close_internal( keyinfo ); - tdb_store_int32( info->tdb, VN_maxsize, uiMaxSize ); - tdb_store_int32( info->tdb, VN_retention, uiRetention ); + tdb_store_int32( info->tdb, EVT_MAXSIZE, uiMaxSize ); + tdb_store_int32( info->tdb, EVT_RETENTION, uiRetention ); return True; } @@ -347,10 +347,10 @@ /* lock the tdb since we have to get 2 records */ - tdb_lock_bystring( info->tdb, VN_next_record, 1 ); - next_record = tdb_fetch_int32( info->tdb, VN_next_record ); - oldest_record = tdb_fetch_int32( info->tdb, VN_oldest_entry ); - tdb_unlock_bystring( info->tdb, VN_next_record ); + tdb_lock_bystring( info->tdb, EVT_NEXT_RECORD, 1 ); + next_record = tdb_fetch_int32( info->tdb, EVT_NEXT_RECORD); + oldest_record = tdb_fetch_int32( info->tdb, EVT_OLDEST_ENTRY); + tdb_unlock_bystring( info->tdb, EVT_NEXT_RECORD); DEBUG( 8, ( "Oldest Record %d; Next Record %d\n", oldest_record, @@ -621,27 +621,29 @@ ( ps, tdb, record_number, &entry ) ) { DEBUG( 8, ( "Retrieved record %d\n", record_number ) ); + /* Now see if there is enough room to add */ - if ( ( ee_new = - read_package_entry( ps, q_u, r_u, - &entry ) ) == NULL ) { + ee_new = read_package_entry( ps, q_u, r_u,&entry ); + if ( !ee_new ) return WERR_NOMEM; - } - if ( r_u->num_bytes_in_resp + ee_new->record.length > q_u->max_read_size ) { r_u->bytes_in_next_record = ee_new->record.length; + /* response would be too big to fit in client-size buffer */ + bytes_left = 0; break; } + add_record_to_resp( r_u, ee_new ); bytes_left -= ee_new->record.length; ZERO_STRUCT( entry ); num_records_read = r_u->num_records - num_records_read; + DEBUG( 10, ( "_eventlog_read_eventlog: read [%d] records for a total of [%d] records using [%d] bytes out of a max of [%d].\n", num_records_read, r_u->num_records, @@ -653,13 +655,12 @@ } - if ( info->flags & EVENTLOG_FORWARDS_READ ) { + if ( info->flags & EVENTLOG_FORWARDS_READ ) record_number++; - } else { + else record_number--; - } - } + return WERR_OK; } Modified: trunk/source/utils/wr_eventlog.c =================================================================== --- trunk/source/utils/wr_eventlog.c 2005-10-10 21:44:01 UTC (rev 10881) +++ trunk/source/utils/wr_eventlog.c 2005-10-10 22:05:06 UTC (rev 10882) @@ -113,19 +113,11 @@ argfname = argv[0]; - if ( !(tdbname = elog_tdbname( argfname )) ) { - fprintf( stderr, "Unable to create eventlog tdb filename!\n"); - return -1; - } - - - if ( !(elog_tdb = elog_open_tdb( tdbname ) ) ) { + if ( !(elog_tdb = elog_open_tdb( argfname ) ) ) { printf( "can't open the eventlog TDB (%s)\n", tdbname ); return -1; } - SAFE_FREE( tdbname ); - ZERO_STRUCT( ee ); /* MUST initialize between records */ while ( !feof( f1 ) ) {