Repository navigation
Expand file tree
/
Copy pathcmd_stream.cpp
More file actions
667 lines (639 loc) · 23.5 KB
/
Copy pathcmd_stream.cpp
File metadata and controls
667 lines (639 loc) · 23.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
// File/layer: cli/cmd_stream.cpp | havne-cli, stream (ADR-0031)
// Testing: UNIT: CliGoldenTest, CliReplayTest, CliRecordTest,
// CliSignalTest, CliConditionsRunTest, CliExitTest,
// CliUsageTest (ctest);
// CliMarkLinesTest (test_cli); BENCH
//
// Public headers only: what any program linking core can do.
#include "condition_lines.h"
#include "default_pick.h"
#include "log_lines.h"
#include "timing_line.h"
#include "jsonl.h"
#include "line_ring.h"
#include "mark_lines.h"
#include "refused_signals.h"
#include "scan_line.h"
#include "sleep_watch.h"
#include "commands.h"
#include "profile_source.h"
#include "session_lines.h"
#include "common.h"
#include "ecuio/core.h"
#include "ecuio/profile.h"
#include "ecuio/recording.h"
#include "ecuio/signals.h"
#include "ecuio/conditions.h"
namespace cmd {
namespace {
constexpr size_t kRingBytes = size_t{1} << 20;
// The ring's size. HAVNE_CLI_RING_BYTES (tests only) makes it small, so
// a golden run fills it: a replay must then wait, not drop. Never below
// one whole line.
size_t ring_bytes()
{
char env[32] = {};
#ifdef _WIN32
const DWORD n =
GetEnvironmentVariableA("HAVNE_CLI_RING_BYTES", env, sizeof env);
if (n == 0 || n >= sizeof env) {
return kRingBytes;
}
#else
const char* value = std::getenv("HAVNE_CLI_RING_BYTES");
if (!value || std::strlen(value) >= sizeof env) {
return kRingBytes;
}
std::memcpy(env, value, std::strlen(value));
#endif
if (!*env) {
return kRingBytes;
}
const unsigned long long v = std::strtoull(env, nullptr, 10);
const size_t floor = kLineBytes + 256;
return v < floor ? floor
: v > kRingBytes ? kRingBytes
: static_cast<size_t>(v);
}
// What the callbacks share with the main thread
struct Stream {
cli::LineRing ring;
bool wait = false; // a replay: wait for room, never drop
uint64_t limit = 0; // --count; 0 = none
std::atomic<uint64_t> covered{0}; // frames written or dropped, up to limit
// The worker's own: frames seen, and whether the last one was
// written (its values follow it, or not)
uint64_t seen = 0;
bool last_written = false;
// --conditions: each condition's key by its index, set before start
// and never changed after; the events no line was written for
std::vector<std::string> condition_keys;
std::vector<uint8_t> condition_link_terms;
std::atomic<uint64_t> conditions_dropped{0};
};
void on_frame(const ecuio_frame_t* f, void* user)
{
auto* s = static_cast<Stream*>(user);
const uint64_t n = ++s->seen;
if (s->limit && n > s->limit) {
s->last_written = false;
return;
}
char buf[kLineBytes];
cli::Line l(buf, sizeof buf);
l.raw("{\"type\":\"frame\"");
l.key("t_us");
l.u64(f->timestamp_us);
l.key("id");
l.hex_id(f->arbitration_id);
l.key("ch");
l.u64(f->channel_id);
l.key("flags");
l.u64(f->flags);
l.key("data");
l.hex_bytes(f->data, f->data_length < ECUIO_FRAME_DATA_MAX
? f->data_length
: ECUIO_FRAME_DATA_MAX);
l.ch('}');
s->last_written = l.finish() && s->ring.push(cli::LineKind::Frame, l.data(),
l.size(), s->wait);
s->covered.store(n, std::memory_order_release);
}
// A frame's condition events (ADR-0063), after its values line: a line
// each, only for a frame that was written; a link change's, which have no
// frame, whenever they come. An event with no line is a change the
// reader never sees, so each is counted for the end line.
void on_conditions(const ecuio_condition_event_t* events, uint32_t count,
void* user)
{
auto* s = static_cast<Stream*>(user);
const uint64_t lost = cli::write_condition_events(
events, count, s->condition_keys, s->last_written,
s->limit != 0 && s->seen > s->limit,
[s](const char* line, size_t n) {
return s->ring.push(cli::LineKind::Condition, line, n, s->wait);
},
&s->condition_link_terms);
if (lost != 0) {
s->conditions_dropped.fetch_add(lost, std::memory_order_relaxed);
}
}
void on_values(const ecuio_value_batch_t* batch, void* user)
{
auto* s = static_cast<Stream*>(user);
if (!s->last_written) {
return;
}
char buf[kLineBytes];
cli::Line l(buf, sizeof buf);
l.raw("{\"type\":\"values\"");
l.key("t_us");
l.u64(batch->timestamp_us);
l.key("id");
l.hex_id(batch->arbitration_id);
l.key("values");
l.ch('[');
for (uint32_t i = 0; i < batch->count; ++i) {
const ecuio_value_t& v = batch->values[i];
if (i) {
l.ch(',');
}
l.ch('{');
l.key("id");
l.u64(v.signal_id);
if (v.kind == ECUIO_VALUE_ENUM) {
// The raw number, and its label when the set has one
// (ADR-0051): the label is at most ECUIO_ENUM_LABEL_MAX bytes
l.key("value");
l.number(v.value);
if (v.text) {
l.key("label");
l.string(v.text, v.text_len, ECUIO_ENUM_LABEL_MAX);
}
} else if (v.text) {
l.key("text");
// Room for ,"cut":true}]}\n after a cut text
const size_t limit = l.room() > 32 ? l.room() - 32 : 0;
if (l.string(v.text, v.text_len, limit) < v.text_len) {
l.key("cut");
l.raw("true");
}
} else {
l.key("value");
l.number(v.value);
}
l.ch('}');
}
l.raw("]}");
if (l.finish()) {
s->ring.push(cli::LineKind::Values, l.data(), l.size(), s->wait);
}
}
void read_marks(std::shared_ptr<MarkQueue> q)
{
cli::MarkLines split;
const auto push = [&q](const std::string& line) {
std::lock_guard<std::mutex> g(q->m);
q->lines.push_back(line);
};
char buf[1024];
for (;;) {
size_t n = 0;
#ifdef _WIN32
HANDLE in = GetStdHandle(STD_INPUT_HANDLE);
if (in == nullptr || in == INVALID_HANDLE_VALUE) {
break;
}
DWORD mode = 0;
if (GetConsoleMode(in, &mode)) {
// A console types UTF-16; ReadFile would give its code page's
// bytes, not UTF-8
wchar_t w[256];
DWORD got = 0;
if (!ReadConsoleW(in, w, 256, &got, nullptr) || got == 0) {
break;
}
const int len =
WideCharToMultiByte(CP_UTF8, 0, w, static_cast<int>(got), buf,
sizeof buf, nullptr, nullptr);
if (len <= 0) {
continue;
}
n = static_cast<size_t>(len);
} else {
DWORD got = 0;
if (!ReadFile(in, buf, sizeof buf, &got, nullptr) || got == 0) {
break;
}
n = got;
}
#else
const ssize_t got = ::read(0, buf, sizeof buf);
if (got < 0 && errno == EINTR) {
continue;
}
if (got <= 0) {
break;
}
n = static_cast<size_t>(got);
#endif
split.feed(buf, n, push);
}
split.finish(push);
}
// The end line's faults: what a replay's ?faults= did (ADR-0041)
void write_faults(cli::Line& l, const ecuio_session_t* session)
{
ecuio_replay_faults_t f;
if (ecuio_session_get_replay_faults(session, &f) != ECUIO_OK) {
return;
}
l.key("faults");
l.ch('{');
l.key("frames");
l.u64(f.frames);
l.key("dropped");
l.u64(f.dropped);
l.key("overflowed");
l.u64(f.overflowed);
l.key("corrupted");
l.u64(f.corrupted);
l.key("truncated");
l.u64(f.truncated);
l.key("stalled");
l.u64(f.stalled);
l.ch('}');
}
} // namespace
int run_stream(const StreamArgs& args)
{
Output out;
auto stream = std::unique_ptr<Stream>(new (std::nothrow) Stream);
if (!stream || !stream->ring.init(ring_bytes())) {
std::fprintf(stderr, "havne-cli: out of memory for the output ring\n");
return kExitFailed;
}
std::vector<char> drained;
try {
drained.resize(stream->ring.capacity());
} catch (const std::bad_alloc&) {
std::fprintf(stderr, "havne-cli: out of memory for the output ring\n");
return kExitFailed;
}
stream->limit = args.count;
write_start(out);
// --conditions, else a replay's own copy
ecuio_condition_set_t* conditions = nullptr;
if (args.conditions != nullptr) {
std::string why;
ecuio_status_t loaded = ECUIO_OK;
conditions = load_conditions_file(args.conditions, &loaded, &why);
if (conditions == nullptr) {
write_error(out, loaded, why.c_str());
return ended(out, kExitConnect);
}
} else {
conditions = recording_conditions(args.uri);
}
const char* conditions_source =
args.conditions != nullptr ? "file" : "recording";
const bool judging = conditions != nullptr;
ecuio_session_t* session = nullptr;
std::string detail;
ecuio_status_t st = create_within(out, args.uri, &session, &detail);
if (st != ECUIO_OK) {
write_error(out, st, detail.c_str());
ecuio_condition_set_free(conditions);
return ended(out, kExitConnect);
}
ecuio_session_info_t info;
std::memset(&info, 0, sizeof info);
ecuio_session_get_info(session, &info);
const bool replay = info.backend == ECUIO_BACKEND_REPLAY;
stream->wait = replay;
const bool replay_ends =
replay && !(info.flags & ECUIO_SESSION_INFO_REPLAY_LOOP);
write_session(out, session, info);
ShownConditions shown;
if (conditions != nullptr) {
if (!attach_conditions(out, session, conditions, conditions_source,
&shown)) {
out.flush();
ecuio_session_destroy(session);
return ended(out, kExitConnect);
}
conditions = nullptr;
stream->condition_keys = shown.keys;
stream->condition_link_terms = shown.link_terms;
ecuio_register_conditions_callback(session, on_conditions,
stream.get());
}
// --pick ranked before a recording attaches, so its header names the
// pick; as in the app, a refused pick leaves the whole set asked
if (args.pick_ranked) {
const ecuio_signal_set_t* set = ecuio_session_signal_set(session);
const bool pick_only = session_pick_only(session);
const std::vector<uint16_t> ids = cli::default_pick(set, {}, pick_only);
if (!session_asks(session)) {
std::fprintf(stderr, "havne-cli: the session asks no signal: "
"--pick ranked picks none\n");
} else if (ids.empty()) {
std::fprintf(stderr,
pick_only ? "havne-cli: the profile ranks no signal "
"and is asked only what is picked: "
"--pick ranked asks none\n"
: "havne-cli: the profile ranks no signal: "
"--pick ranked asks every one\n");
} else if (ecuio_session_set_focus_with(
session, ids.data(), static_cast<uint32_t>(ids.size()),
0, ECUIO_FOCUS_DEFAULT_PICK) != ECUIO_OK) {
std::fprintf(stderr, "havne-cli: asking %s signal: %s\n",
pick_only ? "no" : "every", ecuio_last_error_detail());
} else {
BigLine b(cli::focus_line_bytes(ids.size()));
cli::focus_line(b.line, set, ids, 0, true, session_signal_file());
write_line(out, b.line);
}
} else if (session_pick_only(session)) {
std::fprintf(stderr, "havne-cli: the profile is asked only what is "
"picked: nothing is asked (--pick ranked, or log "
"--signal)\n");
}
ecuio_recorder_t* recorder = nullptr;
bool recording_failed = false;
if (args.record != nullptr &&
!open_recording(out, session, args.record, args.label, &recorder)) {
out.flush();
ecuio_session_destroy(session);
return ended(out, kExitFailed);
}
// A read that completed at create (the mock's) comes first; the rest
// as they complete
const uint32_t channels = module_count(info);
uint32_t diag_generations[ECUIO_MAX_CHANNELS] = {};
uint32_t identity_generations[ECUIO_MAX_CHANNELS] = {};
char vehicle_vin[ECUIO_VIN_TEXT_LEN] = "";
poll_identity(out, session, channels, identity_generations, vehicle_vin);
poll_diagnostics(out, session, channels, diag_generations);
cli::ScanSeen scan_seen[ECUIO_MAX_CHANNELS] = {};
cli::SessionSeen session_seen[ECUIO_MAX_CHANNELS] = {};
ecuio_channel_support_t scan_reports[ECUIO_MAX_CHANNELS] = {};
poll_scan(out, session, channels, scan_seen, session_seen, scan_reports);
// Judged from the values core decodes, so only with --values
const ecuio_signal_set_t* set = ecuio_session_signal_set(session);
std::vector<uint16_t> absent_read(
(args.values && set != nullptr && set->defs != nullptr) ? set->count
: 0u);
std::vector<uint16_t> absent_last;
std::vector<cli::RefusedSignal> refused_last;
std::vector<cli::RefusedMore> refused_more_last;
cli::TimingSnapshots timing_snaps;
std::vector<ecuio_request_timing_t> timing_rows(ECUIO_PROFILE_MAX_REQUESTS);
if (args.values) {
write_signals(out, set, session_signal_file());
}
out.flush();
ecuio_register_frame_callback(session, on_frame, stream.get());
if (args.values) {
ecuio_register_values_callback(session, on_values, stream.get());
}
install_handlers();
// --until-scanned with no did= range to scan has nothing to wait for:
// it ends before it starts
const bool nothing_to_scan =
args.until_scanned && !cli::scans_any(scan_reports, channels);
st = nothing_to_scan ? ECUIO_OK : ecuio_session_start(session);
if (st != ECUIO_OK) {
write_error(out, st);
out.flush();
ecuio_session_close(session);
ecuio_session_destroy(session);
close_recording(out, &recorder, "the session didn't start",
&recording_failed);
return ended(out, kExitConnect);
}
std::shared_ptr<MarkQueue> marks;
if (recorder != nullptr) {
try {
marks = std::make_shared<MarkQueue>();
std::thread(read_marks, marks).detach();
} catch (const std::exception&) {
marks.reset(); // no marks, the recording goes on
}
}
// Session time's clock (ADR-0033): --seconds counts a sleep too
const uint64_t started = ecuio_clock_us();
cli::SleepWatch sleep_watch(ecuio_clock_slept_us());
int32_t last_error = ECUIO_OK;
uint32_t episodes = 0;
const char* reason = nothing_to_scan ? "nothing-to-scan" : nullptr;
while (!reason) {
const size_t n = stream->ring.drain(drained.data(), kPoll);
out.write(drained.data(), n);
out.flush();
if (out.failed) {
break;
}
const uint64_t covered =
stream->covered.load(std::memory_order_acquire);
if (g_interrupted.load()) {
reason = "interrupted";
} else if (args.count && covered >= args.count) {
reason = "count";
} else if (replay_ends && replay_done(session, info, covered)) {
reason = "replay-end";
} else if (args.seconds &&
ecuio_clock_us() - started >= args.seconds * 1000000u) {
reason = "seconds";
} else if (args.until_scanned &&
cli::scans_complete(scan_reports, channels)) {
reason = "scanned";
}
if (const uint64_t slept = sleep_watch.poll(ecuio_clock_slept_us())) {
char buf[64];
cli::Line l(buf, sizeof buf);
l.raw("{\"type\":\"slept\"");
l.key("us");
l.u64(slept);
l.ch('}');
write_line(out, l);
}
poll_identity(out, session, channels, identity_generations,
vehicle_vin);
poll_diagnostics(out, session, channels, diag_generations);
poll_scan(out, session, channels, scan_seen, session_seen,
scan_reports);
poll_absent(out, session, absent_read, absent_last);
if (args.values) {
poll_refused(out, set, scan_reports, channels, refused_last,
refused_more_last);
}
poll_timing(out, session, timing_snaps, timing_rows, false);
poll_recording(out, recorder, marks.get(), &recording_failed);
poll_conditions(out, session, &shown);
poll_health(out, session, &last_error, &episodes);
// A replay whose file changed has stopped, short of its last
// frame: the health line above says so, then the stream ends
if (!reason && replay && last_error == ECUIO_ERR_RECORDING_CHANGED) {
reason = "recording-changed";
}
}
// The loop left on a failed output (a closed pipe, a full stdout):
// nothing more is written, but the recording's close needs its why
if (reason == nullptr) {
reason = "output-failed";
}
// Close joins the worker, whose last callbacks may still be pushing
// (a replay waiting for room): keep draining until it returns. With
// the output gone, nothing drains, so the waits end instead.
if (out.failed) {
stream->ring.stop();
}
std::atomic<bool> closed{false};
std::thread closer([&] {
ecuio_session_close(session);
closed.store(true);
stream->ring.wake();
});
const auto closing = std::chrono::steady_clock::now();
while (!closed.load()) {
const size_t n = stream->ring.drain(drained.data(), kPoll);
out.write(drained.data(), n);
if (out.failed) {
stream->ring.stop();
}
// Interrupted and the close still waits (an adapter's teardown):
// the recording ends whole now, the session going on unrecorded
if (recorder != nullptr && g_interrupted.load() &&
std::chrono::steady_clock::now() - closing >= kRecordingCloseWait) {
close_recording(out, &recorder,
"interrupted: the session's close didn't finish",
&recording_failed);
}
}
closer.join();
out.write(drained.data(),
stream->ring.drain(drained.data(), std::chrono::milliseconds(0)));
int code = kExitOk;
poll_recording(out, recorder, marks.get(), &recording_failed);
char buf[512];
cli::Line l(buf, sizeof buf);
if (!out.failed) {
poll_scan(out, session, channels, scan_seen, session_seen, scan_reports,
true);
poll_timing(out, session, timing_snaps, timing_rows, true);
uint64_t covered = stream->covered.load();
if (args.count && covered > args.count) {
covered = args.count;
}
l.raw("{\"type\":\"end\"");
l.key("reason");
l.string(reason, SIZE_MAX);
l.key("frames");
l.u64(covered);
l.key("dropped_frames");
l.u64(stream->ring.dropped_frames());
l.key("dropped_values");
l.u64(stream->ring.dropped_values());
if (judging) {
l.key("conditions_dropped");
l.u64(stream->conditions_dropped.load());
}
if (info.flags & ECUIO_SESSION_INFO_REPLAY_FAULTS) {
write_faults(l, session);
}
write_isotp(l, session);
l.ch('}');
}
// The recording's last note is the end line; it closes after its
// session, as the app's does
if (recorder != nullptr && l.size() > 0) {
const std::string end(l.data(), l.size());
ecuio_recorder_note(recorder, end.c_str());
}
ecuio_session_destroy(session);
const std::string why = std::string("havne-cli: ") + reason;
close_recording(out, &recorder, why.c_str(), &recording_failed);
if (!out.failed) {
write_line(out, l);
out.flush();
}
if (!out.ok() || recording_failed) {
code = kExitFailed;
}
#ifdef _WIN32
g_done.store(true);
#endif
return code;
}
namespace {
// The checks across stream's options: -1 to go on, else the exit code
int check_stream_args(const StreamArgs& args)
{
if (!args.uri) {
std::fprintf(stderr, "havne-cli: stream needs a URI\n");
usage(stderr);
return kExitUsage;
}
if (args.label && !args.record) {
std::fprintf(stderr, "havne-cli: --label names a --record's folder\n");
usage(stderr);
return kExitUsage;
}
if (args.signals != nullptr && args.plugin != nullptr) {
std::fprintf(stderr, "havne-cli: --signals and --plugin each give "
"the profile: one at a time\n");
usage(stderr);
return kExitUsage;
}
return -1;
}
} // namespace
// stream's arguments and its profile, then run_stream
int cmd_stream(int argc, char** argv)
{
StreamArgs args;
for (int i = 2; i < argc; ++i) {
const std::string a = argv[i];
if (a == "--values") {
args.values = true;
} else if (a == "--until-scanned") {
args.until_scanned = true;
} else if (a == "--count" && i + 1 < argc) {
if (!parse_count(argv[++i], args.count)) {
std::fprintf(
stderr,
"havne-cli: --count takes a whole number above 0\n");
return kExitUsage;
}
} else if (a == "--seconds" && i + 1 < argc) {
if (!parse_run_seconds(argv[++i], args.seconds)) {
std::fprintf(stderr, "havne-cli: %s\n", cli::run_seconds_why());
return kExitUsage;
}
} else if (a == "--record" && i + 1 < argc) {
args.record = argv[++i];
if (*args.record == '\0') {
std::fprintf(stderr, "havne-cli: --record takes a folder\n");
return kExitUsage;
}
} else if (a == "--label" && i + 1 < argc) {
args.label = argv[++i];
} else if (a == "--signals" && i + 1 < argc) {
args.signals = argv[++i];
} else if (a == "--plugin" && i + 1 < argc) {
args.plugin = argv[++i];
} else if (a == "--conditions" && i + 1 < argc &&
args.conditions == nullptr && *argv[i + 1] != '\0') {
args.conditions = argv[++i];
} else if (a == "--conditions") {
std::fprintf(stderr,
"havne-cli: --conditions takes one condition file\n");
return kExitUsage;
} else if (a == "--pick") {
if (i + 1 >= argc || !cli::parse_pick(argv[++i])) {
std::fprintf(stderr, "havne-cli: %s\n", cli::pick_why());
return kExitUsage;
}
args.pick_ranked = true;
} else if (a.rfind("--", 0) == 0 || args.uri) {
std::fprintf(stderr, "havne-cli: unexpected '%s'\n", argv[i]);
usage(stderr);
return kExitUsage;
} else {
args.uri = argv[i];
}
}
const int checked = check_stream_args(args);
if (checked >= 0) {
return checked;
}
std::string opened;
const int rc =
take_profile_source(args.signals, args.plugin, &args.uri, &opened);
if (rc >= 0) {
return rc;
}
return run_stream(args);
}
} // namespace cmd