diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/netlist/build/makefile | 13 | ||||
-rw-r--r-- | src/lib/netlist/plib/pmain.cpp | 87 | ||||
-rw-r--r-- | src/lib/netlist/plib/pmain.h | 69 | ||||
-rw-r--r-- | src/lib/netlist/plib/poptions.cpp | 1 | ||||
-rw-r--r-- | src/lib/netlist/plib/poptions.h | 1 | ||||
-rw-r--r-- | src/lib/netlist/plib/pstream.cpp | 27 | ||||
-rw-r--r-- | src/lib/netlist/prg/nltool.cpp | 135 | ||||
-rw-r--r-- | src/lib/netlist/prg/nlwav.cpp | 79 |
8 files changed, 295 insertions, 117 deletions
diff --git a/src/lib/netlist/build/makefile b/src/lib/netlist/build/makefile index 70ee274a9f0..6033494f503 100644 --- a/src/lib/netlist/build/makefile +++ b/src/lib/netlist/build/makefile @@ -63,6 +63,8 @@ POBJS := \ $(POBJ)/pstream.o \ $(POBJ)/putil.o \ +PMAIN := $(POBJ)/pmain.o + NLOBJS := \ $(NLOBJ)/nl_base.o \ $(NLOBJ)/nl_parser.o \ @@ -130,7 +132,7 @@ NLOBJS := \ $(NLOBJ)/solver/nld_matrix_solver.o \ $(NLOBJ)/tools/nl_convert.o \ -ALL_OBJS = $(OBJS) $(NLOBJ)/prg/nltool.o $(NLOBJ)/prg/nlwav.o +ALL_OBJS = $(OBJS) $(PMAIN) $(NLOBJ)/prg/nltool.o $(NLOBJ)/prg/nlwav.o SOURCES = $(patsubst $(OBJ)%, $(SRC)%, $(ALL_OBJS:.o=.cpp)) MAKEFILE_TARGETS_WITHOUT_INCLUDE := clean doc clang mingw @@ -151,11 +153,11 @@ clean: # nltool #------------------------------------------------- -nltool: $(OBJ)/prg/nltool.o $(OBJS) +nltool: $(OBJ)/prg/nltool.o $(PMAIN) $(OBJS) @echo Linking $@... $(LD) -o $@ $(LDFLAGS) $^ $(LIBS) -nlwav: $(OBJ)/prg/nlwav.o $(OBJS) +nlwav: $(OBJ)/prg/nlwav.o $(PMAIN) $(OBJS) @echo Linking $@... $(LD) -o $@ $(LDFLAGS) $^ $(LIBS) @@ -175,7 +177,7 @@ maketree: $(sort $(OBJDIRS)) .PHONY: clang clang-5 mingw doc clang: - $(MAKE) CC=clang++ LD=clang++ CEXTRAFLAGS="-march=native -Weverything -Werror -Wno-unreachable-code -Wno-padded -Wno-weak-vtables -Wno-missing-variable-declarations -Wconversion -Wno-c++98-compat -Wno-float-equal -Wno-global-constructors -Wno-c++98-compat-pedantic -Wno-format-nonliteral -Wno-weak-template-vtables -Wno-exit-time-destructors" + $(MAKE) CC=clang++ LD=clang++ CEXTRAFLAGS="-march=native -Weverything -Werror -Wno-unreachable-code -Wno-padded -Wno-weak-vtables -Wno-missing-variable-declarations -Wconversion -Wno-c++98-compat -Wno-float-equal -Wno-global-constructors -Wno-c++98-compat-pedantic -Wno-format-nonliteral -Wno-weak-template-vtables -Wno-exit-time-destructors" clang-5: $(MAKE) CC=clang++-5.0 LD=clang++-5.0 CEXTRAFLAGS="-march=native -Weverything -Werror -Wno-unreachable-code -Wno-padded -Wno-weak-vtables -Wno-missing-variable-declarations -Wconversion -Wno-c++98-compat -Wno-float-equal -Wno-global-constructors -Wno-c++98-compat-pedantic -Wno-format-nonliteral -Wno-weak-template-vtables -Wno-exit-time-destructors" @@ -186,7 +188,8 @@ clang-5: # FIXME: -Wunreachable-code : False warnings, this a documented clang bug: https://llvm.org/bugs/show_bug.cgi?id=28994 mingw: - $(MAKE) LDEXTRAFLAGS="-Wl,--subsystem,console" LIBS= MD=@mkdir.exe SHELL=sh.exe + $(MAKE) CEXTRAFLAGS="-DUNICODE -D_UNICODE -D_WIN32_WINNT=0x0501 -DWIN32_LEAN_AND_MEAN" \ + LDEXTRAFLAGS="-Wl,--subsystem,console -municode" LIBS= MD=@mkdir.exe SHELL=sh.exe # # FIXME: Unicode diff --git a/src/lib/netlist/plib/pmain.cpp b/src/lib/netlist/plib/pmain.cpp new file mode 100644 index 00000000000..93c4076bac2 --- /dev/null +++ b/src/lib/netlist/plib/pmain.cpp @@ -0,0 +1,87 @@ +// license:GPL-2.0+ +// copyright-holders:Couriersud +/* + * pmain.cpp + * + */ + +#include "pmain.h" + +#ifdef _WIN32 +#include <windows.h> +#include <string.h> +#include <tchar.h> +#endif + +namespace plib { + + #ifdef _WIN32 + static pstring toutf8(const wchar_t *w) + { + auto wlen = wcslen(w); + int dst_char_count = WideCharToMultiByte(CP_UTF8, 0, w, wlen, nullptr, 0, nullptr, nullptr); + char *buf = new char[dst_char_count + 1]; + WideCharToMultiByte(CP_UTF8, 0, w, wlen, buf, dst_char_count, nullptr, nullptr); + buf[dst_char_count] = 0; + auto ret = pstring(buf, pstring::UTF8); + delete [] buf; + return ret; + } + #endif + +/*************************************************************************** + Application +***************************************************************************/ + + app::app() + : options() + , pout_strm() + , perr_strm() + , pout(pout_strm) + , perr(perr_strm) + { + + } + + app::~app() + { + + } + + int app::main_utfX(int argc, char *argv[]) + { + auto r = this->parse(argc, argv); + int ret = 0; + + if (r != argc) + { + this->perr("Error parsing {}\n", argv[r]); + //FIXME: usage_short + this->perr(this->usage()); + ret = 1; + } + else + ret = this->execute(); + + return ret; + } + +#ifdef _WIN32 + int app::main_utfX(int argc, wchar_t *argv[]) + { + std::vector<pstring> argv_vectors(argc); + std::vector<char *> utf8_argv(argc); + + // convert arguments to UTF-8 + for (int i = 0; i < argc; i++) + { + argv_vectors[i] = toutf8(argv[i]); + utf8_argv[i] = const_cast<char *>(argv_vectors[i].c_str()); + } + + // run utf8_main + return main_utfX(argc, utf8_argv.data()); + } +#endif + +} // namespace plib diff --git a/src/lib/netlist/plib/pmain.h b/src/lib/netlist/plib/pmain.h new file mode 100644 index 00000000000..e2f84b90de6 --- /dev/null +++ b/src/lib/netlist/plib/pmain.h @@ -0,0 +1,69 @@ +// license:GPL-2.0+ +// copyright-holders:Couriersud +/* + * poptions.h + * + */ + +#pragma once + +#ifndef PMAIN_H_ +#define PMAIN_H_ + +#include "poptions.h" +#include "pstring.h" +#include "putil.h" +#include "pstream.h" + +#include <memory> +#include <cwchar> + +#ifdef _WIN32 +#define PMAIN(appclass) \ +extern "C" int wmain(int argc, wchar_t *argv[]) { return plib::app::mainrun<appclass, wchar_t>(argc, argv); } +#else +#define PMAIN(appclass) \ +int main(int argc, char *argv[]) { return plib::app::mainrun<appclass, char>(argc, argv); } +#endif + + +namespace plib { +/*************************************************************************** + Application +***************************************************************************/ + + class app : public options + { + public: + app(); + virtual ~app(); + + virtual pstring usage() = 0; + virtual int execute() = 0; + + plib::pstdout pout_strm; + plib::pstderr perr_strm; + + plib::putf8_fmt_writer pout; + plib::putf8_fmt_writer perr; + + template <class C, typename T> + static int mainrun(int argc, T *argv[]) + { + auto a = std::unique_ptr<C>(new C); + return a->main_utfX(argc, argv); + } + + private: + int main_utfX(int argc, char *argv[]); +#ifdef _WIN32 + int main_utfX(int argc, wchar_t *argv[]); +#endif + + }; + +} + + + +#endif /* PMAIN_H_ */ diff --git a/src/lib/netlist/plib/poptions.cpp b/src/lib/netlist/plib/poptions.cpp index 775ee6d8810..fc2793c40f3 100644 --- a/src/lib/netlist/plib/poptions.cpp +++ b/src/lib/netlist/plib/poptions.cpp @@ -285,3 +285,4 @@ namespace plib { } } // namespace plib + diff --git a/src/lib/netlist/plib/poptions.h b/src/lib/netlist/plib/poptions.h index f859b2f5b3d..221a7fa2c8a 100644 --- a/src/lib/netlist/plib/poptions.h +++ b/src/lib/netlist/plib/poptions.h @@ -193,7 +193,6 @@ private: pstring m_app; }; - } #endif /* POPTIONS_H_ */ diff --git a/src/lib/netlist/plib/pstream.cpp b/src/lib/netlist/plib/pstream.cpp index efbf2aa2374..c43c3b0a174 100644 --- a/src/lib/netlist/plib/pstream.cpp +++ b/src/lib/netlist/plib/pstream.cpp @@ -5,13 +5,20 @@ * */ +#include "pstream.h" +#include "palloc.h" + #include <cstdio> #include <cstring> #include <cstdlib> #include <algorithm> -#include "pstream.h" -#include "palloc.h" +// VS2015 prefers _dup +#ifdef _WIN32 +#include <io.h> +#else +#include <unistd.h> +#endif namespace plib { @@ -167,7 +174,10 @@ void pofilestream::init() pofilestream::~pofilestream() { if (m_actually_close) + { + fflush(static_cast<FILE *>(m_file)); fclose(static_cast<FILE *>(m_file)); + } } void pofilestream::vwrite(const void *buf, const pos_type n) @@ -175,6 +185,7 @@ void pofilestream::vwrite(const void *buf, const pos_type n) std::size_t r = fwrite(buf, 1, n, static_cast<FILE *>(m_file)); if (r < n) { + //printf("%ld %ld %s\n", r, n, strerror(errno)); if (ferror(static_cast<FILE *>(m_file))) throw file_write_e(m_filename); } @@ -214,7 +225,11 @@ postringstream::~postringstream() // ----------------------------------------------------------------------------- pstderr::pstderr() -: pofilestream(stderr, "<stderr>", false) +#ifdef _WIN32 +: pofilestream(fdopen(_dup(fileno(stderr)), "wb"), "<stderr>", true) +#else +: pofilestream(fdopen(dup(fileno(stderr)), "wb"), "<stderr>", true) +#endif { } @@ -227,7 +242,11 @@ pstderr::~pstderr() // ----------------------------------------------------------------------------- pstdout::pstdout() -: pofilestream(stdout, "<stdout>", false) +#ifdef _WIN32 +: pofilestream(fdopen(_dup(fileno(stdout)), "wb"), "<stdout>", true) +#else +: pofilestream(fdopen(dup(fileno(stdout)), "wb"), "<stdout>", true) +#endif { } diff --git a/src/lib/netlist/prg/nltool.cpp b/src/lib/netlist/prg/nltool.cpp index 4e9875dd06d..446f9b6e2a8 100644 --- a/src/lib/netlist/prg/nltool.cpp +++ b/src/lib/netlist/prg/nltool.cpp @@ -8,18 +8,18 @@ ****************************************************************************/ -#include "netlist/plib/poptions.h" +#include "netlist/plib/pmain.h" #include "netlist/nl_setup.h" #include "netlist/nl_parser.h" #include "netlist/devices/net_lib.h" #include "netlist/tools/nl_convert.h" #include "netlist/solver/nld_solver.h" -class tool_options_t : public plib::options +class tool_app_t : public plib::app { public: - tool_options_t() : - plib::options(), + tool_app_t() : + plib::app(), opt_grp1(*this, "General options", "The following options apply to all commands."), opt_cmd (*this, "c", "cmd", "run", "run:convert:listdevices:static:header:docheader", "run|convert|listdevices|static|header"), opt_file(*this, "f", "file", "-", "file to process (default is stdin)"), @@ -63,13 +63,24 @@ public: plib::option_str_limit opt_type; plib::option_example opt_ex1; plib::option_example opt_ex2; -}; -static plib::pstdout pout_strm; -static plib::pstderr perr_strm; + int execute(); + pstring usage(); + +private: + void run(); + void static_compile(); + + void mac_out(const pstring s, const bool cont = true); + void cmac(const netlist::factory::element_t *e); + void mac(const netlist::factory::element_t *e); + + void create_header(); + void create_docheader(); -static plib::putf8_fmt_writer pout(pout_strm); -static plib::putf8_fmt_writer perr(perr_strm); + void listdevices(); + +}; static NETLIST_START(dummy) /* Standard stuff */ @@ -176,22 +187,13 @@ private: void netlist_tool_t::vlog(const plib::plog_level &l, const pstring &ls) const { pstring err = plib::pfmt("{}: {}\n")(l.name())(ls.c_str()); - pout("{}", err); + // FIXME: ... + //pout("{}", err); if (l == plib::plog_level::FATAL) throw netlist::nl_exception(err); } -// FIXME: usage should go elsewhere -void usage(tool_options_t &opts); - -void usage(tool_options_t &opts) -{ - pout("{}\n", opts.help( - "nltool serves as the Swiss Army knife to run, test and convert netlists.", - "nltool [options]").c_str()); -} - struct input_t { input_t(const netlist::setup_t &setup, const pstring &line) @@ -249,7 +251,7 @@ static std::vector<input_t> read_input(const netlist::setup_t &setup, pstring fn return ret; } -static void run(tool_options_t &opts) +void tool_app_t::run() { plib::chrono::timer<plib::chrono::system_ticks> t; t.start(); @@ -259,18 +261,18 @@ static void run(tool_options_t &opts) nt.init(); - if (!opts.opt_verb()) + if (!opt_verb()) nt.log().verbose.set_enabled(false); - if (opts.opt_quiet()) + if (opt_quiet()) nt.log().warning.set_enabled(false); - nt.read_netlist(opts.opt_file(), opts.opt_name(), - opts.opt_logs(), - opts.opt_defines(), opts.opt_rfolders()); + nt.read_netlist(opt_file(), opt_name(), + opt_logs(), + opt_defines(), opt_rfolders()); - std::vector<input_t> inps = read_input(nt.setup(), opts.opt_inp()); + std::vector<input_t> inps = read_input(nt.setup(), opt_inp()); - double ttr = opts.opt_ttr(); + double ttr = opt_ttr(); t.stop(); pout("startup time ==> {1:5.3f}\n", t.as_seconds() ); @@ -298,7 +300,7 @@ static void run(tool_options_t &opts) pout("{1:f} seconds emulation took {2:f} real time ==> {3:5.2f}%\n", ttr, emutime, ttr/emutime*100.0); } -static void static_compile(tool_options_t &opts) +void tool_app_t::static_compile() { netlist_tool_t nt("netlist"); @@ -307,9 +309,9 @@ static void static_compile(tool_options_t &opts) nt.log().verbose.set_enabled(false); nt.log().warning.set_enabled(false); - nt.read_netlist(opts.opt_file(), opts.opt_name(), - opts.opt_logs(), - opts.opt_defines(), opts.opt_rfolders()); + nt.read_netlist(opt_file(), opt_name(), + opt_logs(), + opt_defines(), opt_rfolders()); plib::putf8_writer w(pout_strm); std::map<pstring, pstring> mp; @@ -325,7 +327,7 @@ static void static_compile(tool_options_t &opts) } -static void mac_out(const pstring s, const bool cont = true) +void tool_app_t::mac_out(const pstring s, const bool cont) { static const unsigned RIGHT = 72; if (cont) @@ -339,7 +341,7 @@ static void mac_out(const pstring s, const bool cont = true) pout("{1}\n", s); } -static void cmac(const netlist::factory::element_t *e) +void tool_app_t::cmac(const netlist::factory::element_t *e) { auto v = plib::psplit(e->param_desc(), ","); pstring vs; @@ -359,7 +361,7 @@ static void cmac(const netlist::factory::element_t *e) mac_out("", false); } -static void mac(const netlist::factory::element_t *e) +void tool_app_t::mac(const netlist::factory::element_t *e) { auto v = plib::psplit(e->param_desc(), ","); pstring vs; @@ -383,7 +385,7 @@ static void mac(const netlist::factory::element_t *e) } } -static void create_header(tool_options_t &opts) +void tool_app_t::create_header() { netlist_tool_t nt("netlist"); @@ -428,7 +430,7 @@ static void create_header(tool_options_t &opts) } -static void create_docheader(tool_options_t &opts) +void tool_app_t::create_docheader() { netlist_tool_t nt("netlist"); @@ -479,13 +481,13 @@ static void create_docheader(tool_options_t &opts) listdevices - list all known devices -------------------------------------------------*/ -static void listdevices(tool_options_t &opts) +void tool_app_t::listdevices() { netlist_tool_t nt("netlist"); nt.init(); - if (!opts.opt_verb()) + if (!opt_verb()) nt.log().verbose.set_enabled(false); - if (opts.opt_quiet()) + if (opt_quiet()) nt.log().warning.set_enabled(false); netlist::factory::list_t &list = nt.setup().factory(); @@ -576,10 +578,16 @@ static const pstring pmf_verbose[] = }; #endif -int main(int argc, char *argv[]) +pstring tool_app_t::usage() +{ + return help( + "nltool serves as the Swiss Army knife to run, test and convert netlists.", + "nltool [options]"); +} + +int tool_app_t::execute() { - tool_options_t opts; - int ret; + tool_app_t opts; /* make SIGFPE actually deliver signals on supoorted platforms */ plib::fpsignalenabler::global_enable(true); @@ -588,20 +596,14 @@ int main(int argc, char *argv[]) //perr("{}", "WARNING: This is Work In Progress! - It may fail anytime\n"); //perr("Update dispatching using method {}\n", pmf_verbose[NL_PMF_TYPE]); //printf("test2 %f\n", std::exp(-14362.38064713)); - if ((ret = opts.parse(argc, argv)) != argc) - { - perr("Error parsing {}\n", argv[ret]); - usage(opts); - return 1; - } - if (opts.opt_help()) + if (opt_help()) { - usage(opts); + pout(usage()); return 0; } - if (opts.opt_version()) + if (opt_version()) { pout( "nltool (netlist) 0.1\n" @@ -615,47 +617,47 @@ int main(int argc, char *argv[]) try { - pstring cmd = opts.opt_cmd(); + pstring cmd = opt_cmd(); if (cmd == "listdevices") - listdevices(opts); + listdevices(); else if (cmd == "run") - run(opts); + run(); else if (cmd == "static") - static_compile(opts); + static_compile(); else if (cmd == "header") - create_header(opts); + create_header(); else if (cmd == "docheader") - create_docheader(opts); + create_docheader(); else if (cmd == "convert") { pstring contents; plib::postringstream ostrm; - if (opts.opt_file() == "-") + if (opt_file() == "-") { plib::pstdin f; ostrm.write(f); } else { - plib::pifilestream f(opts.opt_file()); + plib::pifilestream f(opt_file()); ostrm.write(f); } contents = ostrm.str(); pstring result; - if (opts.opt_type().equals("spice")) + if (opt_type().equals("spice")) { nl_convert_spice_t c; c.convert(contents); result = c.result(); } - else if (opts.opt_type().equals("eagle")) + else if (opt_type().equals("eagle")) { nl_convert_eagle_t c; c.convert(contents); result = c.result(); } - else if (opts.opt_type().equals("rinf")) + else if (opt_type().equals("rinf")) { nl_convert_rinf_t c; c.convert(contents); @@ -667,7 +669,8 @@ int main(int argc, char *argv[]) else { perr("Unknown command {}\n", cmd.c_str()); - usage(opts); + //FIXME: usage_short + perr(usage()); return 1; } } @@ -683,3 +686,7 @@ int main(int argc, char *argv[]) pstring::resetmem(); return 0; } + +PMAIN(tool_app_t) + +//plib::app *appconstructor() { return new tool_app_t(); } diff --git a/src/lib/netlist/prg/nlwav.cpp b/src/lib/netlist/prg/nlwav.cpp index 654df8d2dbb..be2eb7b9947 100644 --- a/src/lib/netlist/prg/nlwav.cpp +++ b/src/lib/netlist/prg/nlwav.cpp @@ -4,15 +4,15 @@ #include "../plib/pstring.h" #include "../plib/plists.h" #include "../plib/pstream.h" -#include "../plib/poptions.h" +#include "../plib/pmain.h" #include "../plib/ppmf.h" #include "../nl_setup.h" -class nlwav_options_t : public plib::options +class nlwav_app : public plib::app { public: - nlwav_options_t() : - plib::options(), + nlwav_app() : + plib::app(), opt_inp(*this, "i", "input", "-", "input file"), opt_out(*this, "o", "output", "-", "output file"), opt_amp(*this, "a", "amp", 10000.0, "amplification after mean correction"), @@ -30,16 +30,16 @@ public: plib::option_bool opt_quiet; plib::option_bool opt_version; plib::option_bool opt_help; -}; -plib::pstdin pin_strm; -plib::pstdout pout_strm; -plib::pstderr perr_strm; + int execute(); + pstring usage(); -plib::putf8_fmt_writer pout(pout_strm); -plib::putf8_fmt_writer perr(perr_strm); + plib::pstdin pin_strm; +private: + void convert1(long sample_rate); + void convert(long sample_rate); +}; -nlwav_options_t opts; /* From: https://ffmpeg.org/pipermail/ffmpeg-devel/2007-October/038122.html * The most compatible way to make a wav header for unknown length is to put @@ -244,17 +244,17 @@ private: wav_t m_wo; }; -static void convert(long sample_rate) +void nlwav_app::convert(long sample_rate) { - plib::postream *fo = (opts.opt_out() == "-" ? &pout_strm : plib::palloc<plib::pofilestream>(opts.opt_out())); - plib::pistream *fin = (opts.opt_inp() == "-" ? &pin_strm : plib::palloc<plib::pifilestream>(opts.opt_inp())); + plib::postream *fo = (opt_out() == "-" ? &pout_strm : plib::palloc<plib::pofilestream>(opt_out())); + plib::pistream *fin = (opt_inp() == "-" ? &pin_strm : plib::palloc<plib::pifilestream>(opt_inp())); plib::putf8_reader reader(*fin); wav_t *wo = plib::palloc<wav_t>(*fo, static_cast<unsigned>(sample_rate)); double dt = 1.0 / static_cast<double>(wo->sample_rate()); double ct = dt; //double mean = 2.4; - double amp = opts.opt_amp(); + double amp = opt_amp(); double mean = 0.0; double means = 0.0; double cursam = 0.0; @@ -317,12 +317,12 @@ static void convert(long sample_rate) #endif } plib::pfree(wo); - if (opts.opt_inp() != "-") + if (opt_inp() != "-") plib::pfree(fin); - if (opts.opt_out() != "-") + if (opt_out() != "-") plib::pfree(fo); - if (!opts.opt_quiet()) + if (!opt_quiet()) { perr("Mean (low freq filter): {}\n", mean); perr("Mean (static): {}\n", means / static_cast<double>(n)); @@ -331,20 +331,20 @@ static void convert(long sample_rate) } } -static void convert1(long sample_rate) +void nlwav_app::convert1(long sample_rate) { - plib::postream *fo = (opts.opt_out() == "-" ? &pout_strm : plib::palloc<plib::pofilestream>(opts.opt_out())); - plib::pistream *fin = (opts.opt_inp() == "-" ? &pin_strm : plib::palloc<plib::pifilestream>(opts.opt_inp())); + plib::postream *fo = (opt_out() == "-" ? &pout_strm : plib::palloc<plib::pofilestream>(opt_out())); + plib::pistream *fin = (opt_inp() == "-" ? &pin_strm : plib::palloc<plib::pifilestream>(opt_inp())); double dt = 1.0 / static_cast<double>(sample_rate); - wavwriter *wo = plib::palloc<wavwriter>(*fo, static_cast<unsigned>(sample_rate), opts.opt_amp()); + wavwriter *wo = plib::palloc<wavwriter>(*fo, static_cast<unsigned>(sample_rate), opt_amp()); aggregator ag(dt, aggregator::callback_type(&wavwriter::process, wo)); log_processor lp(*fin, log_processor::callback_type(&aggregator::process, &ag)); lp.process(); - if (!opts.opt_quiet()) + if (!opt_quiet()) { perr("Mean (low freq filter): {}\n", wo->mean); perr("Mean (static): {}\n", wo->means / static_cast<double>(wo->n)); @@ -353,38 +353,29 @@ static void convert1(long sample_rate) } plib::pfree(wo); - if (opts.opt_inp() != "-") + if (opt_inp() != "-") plib::pfree(fin); - if (opts.opt_out() != "-") + if (opt_out() != "-") plib::pfree(fo); } -static void usage(plib::putf8_fmt_writer &fw) +pstring nlwav_app::usage() { - fw("{}\n", opts.help("Convert netlist log files into wav files.\n", - "nltool [options]")); + return help("Convert netlist log files into wav files.\n", + "nltool [options]"); } -int main(int argc, char *argv[]) +int nlwav_app::execute() { - int ret; - - if ((ret = opts.parse(argc, argv)) != argc) + if (opt_help()) { - perr("Error parsing {}\n", argv[ret]); - usage(perr); - return 1; - } - - if (opts.opt_help()) - { - usage(pout); + pout(usage()); return 0; } - if (opts.opt_version()) + if (opt_version()) { pout( "nlwav (netlist) 0.1\n" @@ -397,13 +388,15 @@ int main(int argc, char *argv[]) } if ((1)) - convert1(opts.opt_rate()); + convert1(opt_rate()); else - convert(opts.opt_rate()); + convert(opt_rate()); return 0; } +PMAIN(nlwav_app) + /* Der Daten-Abschnitt enth??lt die Abtastwerte: Offset L??nge Inhalt Beschreibung |