static struct xmllog_root * parse_xmllog(struct xml_tree *root) { struct xmllog_root *xmlroot; struct xml_tree *p; struct xmllog_entry *xmle; if (root->tag != T_LOG) return elem_err(root, "<log> element expected"); if (!is_empty_text(root)) return 0; if (root->first) elem_err(root, "attributes not allowed for <log>"); xmlroot = (struct xmllog_root*) root; for (p = root->first_down; p; p = p->right) { if (p->tag != T_LOGENTRY) return elem_err(p, "<logentry> element expected"); if (!(xmle = parse_logentry(p))) return 0; XEXPAND2(xmlroot->e); xmlroot->e.v[xmlroot->e.u++] = xmle; } return xmlroot; }
static int DoWriteCommand( int argc, char **argv, bool debugflag, char *exename ) { FILE *f1; char *argfname; ELOG_TDB *etdb; /* fixed constants are bad bad bad */ char linein[1024]; bool is_eor; Eventlog_entry ee; int rcnum; f1 = stdin; if ( !f1 ) { printf( "Can't open STDIN\n" ); return -1; } if ( debugflag ) { printf( "Starting write for eventlog [%s]\n", argv[0] ); display_eventlog_names( ); } argfname = argv[0]; if ( !( etdb = elog_open_tdb( argfname, False ) ) ) { printf( "can't open the eventlog TDB (%s)\n", argfname ); return -1; } ZERO_STRUCT( ee ); /* MUST initialize between records */ while ( !feof( f1 ) ) { if (fgets( linein, sizeof( linein ) - 1, f1 ) == NULL) { break; } linein[strlen( linein ) - 1] = 0; /* whack the line delimiter */ if ( debugflag ) printf( "Read line [%s]\n", linein ); is_eor = False; parse_logentry( ( char * ) &linein, &ee, &is_eor ); /* should we do something with the return code? */ if ( is_eor ) { fixup_eventlog_entry( &ee ); if ( opt_debug ) printf( "record number [%d], tg [%d] , tw [%d]\n", ee.record.record_number, ee.record.time_generated, ee.record.time_written ); if ( ee.record.time_generated != 0 ) { /* printf("Writing to the event log\n"); */ rcnum = write_eventlog_tdb( ELOG_TDB_CTX(etdb), &ee ); if ( !rcnum ) { printf( "Can't write to the event log\n" ); } else { if ( opt_debug ) printf( "Wrote record %d\n", rcnum ); } } else { if ( opt_debug ) printf( "<null record>\n" ); } ZERO_STRUCT( ee ); /* MUST initialize between records */ } } elog_close_tdb( etdb , False ); return 0; }
static int DoWriteCommand( int argc, char **argv, bool debugflag, char *exename ) { FILE *f1; char *argfname; ELOG_TDB *etdb; NTSTATUS status; /* fixed constants are bad bad bad */ char linein[1024]; bool is_eor; struct eventlog_Record_tdb ee; uint32_t record_number = 0; TALLOC_CTX *mem_ctx = talloc_tos(); f1 = stdin; if ( !f1 ) { printf( "Can't open STDIN\n" ); return -1; } if ( debugflag ) { printf( "Starting write for eventlog [%s]\n", argv[0] ); display_eventlog_names( ); } argfname = argv[0]; if ( !( etdb = elog_open_tdb( argfname, False, False ) ) ) { printf( "can't open the eventlog TDB (%s)\n", argfname ); return -1; } ZERO_STRUCT( ee ); /* MUST initialize between records */ while ( !feof( f1 ) ) { if (fgets( linein, sizeof( linein ) - 1, f1 ) == NULL) { break; } if ((strlen(linein) > 0) && (linein[strlen(linein)-1] == '\n')) { linein[strlen(linein)-1] = 0; } if ( debugflag ) printf( "Read line [%s]\n", linein ); is_eor = False; parse_logentry( mem_ctx, ( char * ) &linein, &ee, &is_eor ); /* should we do something with the return code? */ if ( is_eor ) { fixup_eventlog_record_tdb( &ee ); if ( opt_debug ) printf( "record number [%d], tg [%d] , tw [%d]\n", ee.record_number, (int)ee.time_generated, (int)ee.time_written ); if ( ee.time_generated != 0 ) { /* printf("Writing to the event log\n"); */ status = evlog_push_record_tdb( mem_ctx, ELOG_TDB_CTX(etdb), &ee, &record_number ); if ( !NT_STATUS_IS_OK(status) ) { printf( "Can't write to the event log: %s\n", nt_errstr(status) ); } else { if ( opt_debug ) printf( "Wrote record %d\n", record_number ); } } else { if ( opt_debug ) printf( "<null record>\n" ); } ZERO_STRUCT( ee ); /* MUST initialize between records */ } } elog_close_tdb( etdb , False ); return 0; }