/* Last edited on 2015-01-20 16:48:40 by stolfilocal */ /* Converts segment files from old to new format. */ #include #include #include #include #include TYPE Options = struct ??? { char *input; /* Input candidate file name. */ unsigned band; /* Input nominal filtering bandwidth. */ char *chainDir; /* Directory where to find chains. */ char *chainPrefix; /* Chain file name prefix. */ char *output; /* Output candidate file name. */ unsigned nChains; /* Total num of chains. */ } ???; int main(int argc, char **argv ) { { /* with */ ??? o = pz_get_options(int argc, char **argv); ??? chains = GetAllChains(o.nChains)^; chAllData = pz_symbol_chain_read_all( o.chainPrefix, o.band, ".cvc"; sel := chains, header_only := TRUE; dir := o.chainDir ); ??? m = GetSampleNumbers(chAllData.chData^)^; ??? cData = pz_segment_read_old(open_read(o.input & ".seg", TRUE), m); ??? seg = cData.s^; ??? wr = open_write(o.output & ".seg", TRUE); /* do */ pz_segment_write(wr, cData.cmt & UpdateComments(o), seg);; }; } /* Main */ Options pz_get_options(int argc, char **argv ) VAR o: Options; { argparser_t *pp = argparser_new(stderr, argc, argv); argparser_set_help(pp, PROG_NAME " version " PROG_VERS ", usage:\n" PROG_HELP); argparser_set_info(pp, PROG_INFO); argparser_process_help_info_options(pp); { /* with */ /* do */ TRY argparser_get_keyword(pp, "-input"); o.input = argparser_get_next(pp); if (( argparser_keyword_present(pp, "-chainDir") )){ o.chainDir = argparser_get_next(pp) }else{ o.chainDir = "."; }; argparser_get_keyword(pp, "-chainPrefix"); o.chainPrefix = argparser_get_next(pp); argparser_get_keyword(pp, "-band"); o.band = argparser_get_next_int(pp); argparser_get_keyword(pp, "-nChains"); o.nChains = argparser_get_next_int(pp); argparser_get_keyword(pp, "-output"); o.output = argparser_get_next(pp); argparser_finish(pp); EXCEPT | ParseParams.Error ==> fprintf(stderr, "Usage: pz_update_segs \\\n"); fprintf(stderr, " -input NAME \\\n"); fprintf(stderr, " [ -chainDir DIR ] -chainPrefix NAME \\\n"); fprintf(stderr, " -band NUMBER \\\n"); fprintf(stderr, " -nChains NUMBER \\\n"); fprintf(stderr, " -output NAME\n"); Process.Exit(1);; };; }; return o } /* GetOptions */ bool_vec_t *GetAllChains( unsigned n ) { { /* with */ ??? rseen = bool_vec_new(n); ??? seen = rseen^; /* do */ for (k = 0; k < (seen.ne ) ; k++){ seen[k] = TRUE ;}; return rseen; } } /* GetAllChains */ PROCEDURE GetSampleNumbers( ARRAY *OF pz_symbol_chain_read_data ch ): REF int_vec_t = { { /* with */ ??? n = (ch.ne); ??? rm = int_vec_new(n); ??? m = rm^; /* do */ for (k = 0; k <= n-1 ; k++){ m[k] = ch[k].samples; }; return rm; } } /* GetSampleNumbers */ char *UpdateComments( Options *o ) { { /* with */ ??? wr = NEW(TextFILE *).init(); /* do */ fprintf(wr, " input == %s\n", o.input ); fprintf(wr, " chainDir == %s\n", o.chainDir ); fprintf(wr, " chainPrefix == %s\n", o.chainPrefix ); fprintf(wr, " band == %s\n", Fmt.Int(o.band) ); fprintf(wr, " output == %s\n", o.output ); fprintf( wr, "pz_update_segs\n"); return(TextFILE *oText(wr)); } /* ){ */; } /* UpdateComments */ { /* Copyright © 2001 Universidade Estadual de Campinas (UNICAMP). Authors: Helena C. G. Leitão and Jorge Stolfi. This file can be freely distributed, used, and modified, provided that this copyright and authorship notice is preserved, and that any modified versions are clearly marked as such. This software has NO WARRANTY of correctness or applicability for any purpose. Neither the authors nor their employers chall be held responsible for any losses or damages that may result from its use. */