int main(int argc, char *argv[]) { int r=0; int dump=0; int option=0; FILE *inp=NULL; const char *in=NULL; const char *out=NULL; prog=basename(argv[0]); while((option=getopt(argc, argv, "i:ho:p?"))!=-1) { switch(option) { case 'i': in=optarg; break; case 'o': out=optarg; break; case 'p': dump=1; break; case 'h': case '?': default: usage(); return 1; } } if(open_fp(in, &inp, "rb", stdin)) return 1; if(dump) { r=dump_headers(inp); } else { FILE *outp=NULL; if(open_fp(out, &outp, "wb", stdout)) { fclose(inp); return 1; } r=main_work(inp, outp); if(outp) fclose(outp); } if(inp) fclose(inp); if(r) return 1; return 0; }
static struct fzp *fzp_do_open(const char *path, const char *mode, enum fzp_type type) { struct fzp *fzp=NULL; if(!(fzp=fzp_alloc())) goto error; fzp->type=type; switch(type) { case FZP_FILE: if(!(fzp->fp=open_fp(path, mode))) goto error; return fzp; case FZP_COMPRESSED: if(!(fzp->zp=open_zp(path, mode))) goto error; return fzp; default: unknown_type(fzp->type, __func__); goto error; } error: fzp_close(&fzp); return NULL; }
bool sc_trace_file_base::initialize() { if( initialized_ ) return false; initialized_ = true; if( !tracing_initialized_ ) { tracing_initialized_ = true; bool running_regression = ( getenv( "SYSTEMC_REGRESSION" ) != NULL ); // hide some messages during regression if( running_regression ) { sc_report_handler::set_actions( SC_ID_TRACING_TIMESCALE_DEFAULT_ , SC_INFO, SC_DO_NOTHING ); sc_report_handler::set_actions( SC_ID_TRACING_VCD_DUPLICATE_TIME_ , SC_WARNING, SC_DO_NOTHING ); } } // open trace file if(!fp) open_fp(); // setup timescale if( !timescale_set_by_user ) { timescale_unit = sc_get_time_resolution().to_seconds(); std::stringstream ss; ss << sc_get_time_resolution() << " (" << filename_ << ")"; SC_REPORT_INFO( SC_ID_TRACING_TIMESCALE_DEFAULT_ , ss.str().c_str() ); } // initialize derived tracing implementation class (VCD/WIF) do_initialize(); return initialized_; }