int main(int argc, char **argv) { int opt; int use_var = 0; const char *pattern = "/files//*"; struct timeval stop, start; while ((opt = getopt(argc, argv, "n")) != -1) { switch (opt) { case 'n': use_var = 1; break; default: fprintf(stderr, "Usage: %s [-n] [pattern]\n", argv[0]); fprintf(stderr, " without '-n', iterate matches\n"); fprintf(stderr, " with '-n', use a variable and aug_ns_*\n"); exit(EXIT_FAILURE); break; } } struct augeas *aug = aug_init(NULL, NULL, 0); if (optind < argc) pattern = argv[optind]; gettimeofday(&start, NULL); if (use_var) { dump_var(aug, pattern); } else { dump_match(aug, pattern); } gettimeofday(&stop, NULL); print_time_taken(&start, &stop); return 0; }
static list_element * lookup_flow_entries_with_table_id( const uint8_t table_id, const match *match, const uint16_t priority, const bool strict, const bool update_counters ) { assert( valid_table_id( table_id ) ); if ( get_logging_level() >= LOG_DEBUG ) { debug( "Looking up flow entries ( table_id = %#x, match = %p, priority = %u, strict = %s, update_counters = %s ).", table_id, match, priority, strict ? "true" : "false", update_counters ? "true" : "false" ); if ( match != NULL ) { dump_match( match, debug ); } } flow_table *table = get_flow_table( table_id ); if ( table == NULL ) { return NULL; } if ( update_counters ) { increment_lookup_count( table_id ); } list_element *head = NULL; create_list( &head ); for ( list_element *e = table->entries; e != NULL; e = e->next ) { flow_entry *entry = e->data; assert( entry != NULL ); if ( strict ) { if ( entry->priority < priority ) { break; } if ( priority == entry->priority && compare_match_strict( match, entry->match ) ) { if ( update_counters ) { increment_matched_count( table_id ); } append_to_tail( &head, entry ); break; } } else { if ( compare_match( match, entry->match ) ) { if ( update_counters ) { increment_matched_count( table_id ); } append_to_tail( &head, entry ); } } } return head; }
void dump_action( const action *action, void dump_function( const char *format, ... ) ) { assert( action != NULL ); assert( dump_function != NULL ); switch ( action->type ) { case OFPAT_OUTPUT: { ( *dump_function )( "type: OUTPUT ( %#x )", action->type ); ( *dump_function )( "port: %u ( %#x )", action->port, action->port ); ( *dump_function )( "max_len: %u ( %#x )", action->max_len, action->max_len ); } break; case OFPAT_COPY_TTL_OUT: { ( *dump_function )( "type: COPY_TTL_OUT ( %#x )", action->type ); } break; case OFPAT_COPY_TTL_IN: { ( *dump_function )( "type: COPY_TTL_IN ( %#x )", action->type ); } break; case OFPAT_SET_MPLS_TTL: { ( *dump_function )( "type: SET_MPLS_TTL ( %#x )", action->type ); ( *dump_function )( "mpls_ttl: %u ( %#x )", action->mpls_ttl, action->mpls_ttl ); } break; case OFPAT_DEC_MPLS_TTL: { ( *dump_function )( "type: DEC_MPLS_TTL ( %#x )", action->type ); } break; case OFPAT_PUSH_VLAN: { ( *dump_function )( "type: PUSH_VLAN ( %#x )", action->type ); ( *dump_function )( "ethertype: %#x", action->ethertype ); } break; case OFPAT_POP_VLAN: { ( *dump_function )( "type: POP_VLAN ( %#x )", action->type ); } break; case OFPAT_PUSH_MPLS: { ( *dump_function )( "type: PUSH_MPLS ( %#x )", action->type ); ( *dump_function )( "ethertype: %#x", action->ethertype ); } break; case OFPAT_POP_MPLS: { ( *dump_function )( "type: POP_MPLS ( %#x )", action->type ); } break; case OFPAT_SET_QUEUE: { ( *dump_function )( "type: SET_QUEUE ( %#x )", action->type ); ( *dump_function )( "queue_id: %u ( %#x )", action->queue_id, action->queue_id ); } break; case OFPAT_GROUP: { ( *dump_function )( "type: GROUP ( %#x )", action->type ); ( *dump_function )( "group_id: %u ( %#x )", action->group_id, action->group_id ); } break; case OFPAT_SET_NW_TTL: { ( *dump_function )( "type: SET_NW_TTL ( %#x )", action->type ); ( *dump_function )( "nw_ttl: %u ( %#x )", action->nw_ttl, action->nw_ttl ); } break; case OFPAT_DEC_NW_TTL: { ( *dump_function )( "type: DEC_NW_TTL ( %#x )", action->type ); } break; case OFPAT_SET_FIELD: { ( *dump_function )( "type: SET_FIELD ( %#x )", action->type ); dump_match( action->match, dump_function ); } break; case OFPAT_PUSH_PBB: { ( *dump_function )( "type: PUSH_PBB ( %#x )", action->type ); ( *dump_function )( "ethertype: %#x", action->ethertype ); } break; case OFPAT_POP_PBB: { ( *dump_function )( "type: POP_PBB ( %#x )", action->type ); } break; case OFPAT_EXPERIMENTER: { ( *dump_function )( "type: EXPERIMENTER ( %#x )", action->type ); } break; default: { ( *dump_function )( "type: UNDEFINED ( %#x )", action->type ); } break; } ( *dump_function )( "flow entry: %p", action->entry ); }
void print_match (unspos pos1, unspos pos2, unspos length, score s) // pos1 and pos2 are the positions of first character in the match, // .. (origin-0). { static u32 printsUntilFlush = matchFlushFrequency; int outputFormat = currParams->outputFormat; if ((currParams->searchLimit > 0) && (printedForQuery >= currParams->searchLimit)) return; printedForQuery++; if (!strandHeaderPrinted) { print_header (); strandHeaderPrinted = true; } if (infer_scores_dbgShowIdentity) { unspos numer, denom; u32 bin; segment_identity (currParams->seq1, pos1, currParams->seq2, pos2, length, &numer, &denom); bin = identity_bin (numer, denom); // nota bene: positions written as 1-based print_generic (currParams->outputFile, unsposSlashFmt " pct_identity=" unsposSlashFmt " (bin as " identityBinFormat ")", pos1+1, pos2+1, numer, denom, bin_to_identity (bin)); } switch (outputFormat) { case fmtGfa: case fmtGfaNoScore: print_gfa_match (currParams->outputFile, currParams->seq1, pos1, currParams->seq2, pos2, length, (outputFormat == fmtGfa)? s : 0); break; case fmtLav: case fmtLavComment: case fmtLavText: case fmtLavInfScores: print_lav_match (currParams->outputFile, currParams->seq1, pos1, currParams->seq2, pos2, length, s); if (outputFormat == fmtLavText) goto text_format; if (outputFormat == fmtLavInfScores) goto inf_scores_format; break; case fmtLavScore: print_lavscore_match (currParams->outputFile, currParams->seq1, pos1, currParams->seq2, pos2, length, s); break; case fmtAxt: case fmtAxtComment: print_axt_match (currParams->outputFile, currParams->seq1, pos1, currParams->seq2, pos2, length, s, /* comments */ outputFormat==fmtAxtComment, /* extras */ NULL); break; case fmtAxtGeneral: print_axt_match (currParams->outputFile, currParams->seq1, pos1, currParams->seq2, pos2, length, s, /* comments */ false, /* extras */ currParams->outputInfo); break; case fmtMaf: case fmtMafNoComment: print_maf_match (currParams->outputFile, currParams->seq1, pos1, currParams->seq2, pos2, length, s, /* comments */ false); break; case fmtMafComment: print_maf_match (currParams->outputFile, currParams->seq1, pos1, currParams->seq2, pos2, length, s, /* comments */ true); break; case fmtSoftSam: case fmtSoftSamNoHeader: print_sam_match (currParams->outputFile, currParams->seq1, pos1, currParams->seq2, pos2, length, s, /* softMasking */ true, currParams->samRGTags); break; case fmtHardSam: case fmtHardSamNoHeader: print_sam_match (currParams->outputFile, currParams->seq1, pos1, currParams->seq2, pos2, length, s, /* softMasking */ false, currParams->samRGTags); break; case fmtCigar: print_cigar_match (currParams->outputFile, currParams->seq1, pos1, currParams->seq2, pos2, length, s, /* withInfo */ true, /* markMismatches */ false, /* letterAfter */ false, /* hideSingles */ false, /* lowerCase */ false, /* withNewLine */ true); break; case fmtGenpaf: case fmtGenpafNoHeader: case fmtGenpafNameHeader: case fmtGenpafBlast: case fmtGenpafBlastNoHeader: print_genpaf_match (currParams->outputFile, currParams->seq1, pos1, currParams->seq2, pos2, length, s, currParams->outputInfo); break; case fmtText: case fmtZeroText: text_format: print_text_align_match (currParams->outputFile, currParams->seq1, pos1, currParams->seq2, pos2, length, s, (outputFormat!=fmtZeroText), currParams->textContext); break; case fmtDiffs: case fmtDiffsNoBlocks: print_align_diffs_match (currParams->outputFile, currParams->seq1, pos1, currParams->seq2, pos2, length, (outputFormat == fmtDiffs), currParams->nIsAmbiguous); break; case fmtHspComp: print_match_composition (currParams->outputFile, currParams->seq1, pos1, currParams->seq2, pos2, length, s, currParams->hitSeed, currParams->step); break; case fmtInfStats: infer_stats_from_match (currParams->seq1, pos1, currParams->seq2, pos2, length); break; case fmtInfScores: inf_scores_format: gather_stats_from_match (currParams->seq1, pos1, currParams->seq2, pos2, length); break; case fmtIdDist: identity_dist_from_match (currParams->seq1, pos1, currParams->seq2, pos2, length); break; case fmtDeseed: dump_match (currParams->outputFile, currParams->seq1, pos1, currParams->seq2, pos2, length); printf ("\n"); break; case fmtNone: ; // (do nothing) break; default: suicidef ("internal error, in print_match, outputFormat=%d", outputFormat); } if (currParams->dotplotFile != NULL) print_genpaf_match (currParams->dotplotFile, currParams->seq1, pos1, currParams->seq2, pos2, length, s, currParams->dotplotKeys); if (--printsUntilFlush == 0) { fflush (currParams->outputFile); printsUntilFlush = matchFlushFrequency; } }