2015-03-31 13:28:11 +02:00
|
|
|
/** Node type: File
|
|
|
|
*
|
|
|
|
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
2017-03-03 20:20:13 -04:00
|
|
|
* @copyright 2017, Institute for Automation of Complex Power Systems, EONERC
|
2017-04-27 12:56:43 +02:00
|
|
|
* @license GNU General Public License (version 3)
|
|
|
|
*
|
|
|
|
* VILLASnode
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* any later version.
|
2017-05-05 19:24:16 +00:00
|
|
|
*
|
2017-04-27 12:56:43 +02:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2017-05-05 19:24:16 +00:00
|
|
|
*
|
2017-04-27 12:56:43 +02:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2015-06-02 21:53:04 +02:00
|
|
|
*********************************************************************************/
|
2015-03-31 13:28:11 +02:00
|
|
|
|
|
|
|
#include <unistd.h>
|
2015-08-09 23:52:44 +02:00
|
|
|
#include <string.h>
|
2017-06-17 03:13:42 +02:00
|
|
|
#include <inttypes.h>
|
2015-03-31 13:28:11 +02:00
|
|
|
|
2017-12-09 02:19:28 +08:00
|
|
|
#include <villas/nodes/file.h>
|
|
|
|
#include <villas/utils.h>
|
|
|
|
#include <villas/timing.h>
|
|
|
|
#include <villas/queue.h>
|
|
|
|
#include <villas/plugin.h>
|
|
|
|
#include <villas/io.h>
|
2015-11-23 16:42:43 +01:00
|
|
|
|
2015-10-14 12:11:33 +02:00
|
|
|
static char * file_format_name(const char *format, struct timespec *ts)
|
|
|
|
{
|
|
|
|
struct tm tm;
|
|
|
|
char *buf = alloc(FILE_MAX_PATHLEN);
|
2017-05-05 19:24:16 +00:00
|
|
|
|
2015-10-14 12:11:33 +02:00
|
|
|
/* Convert time */
|
|
|
|
gmtime_r(&ts->tv_sec, &tm);
|
|
|
|
|
|
|
|
strftime(buf, FILE_MAX_PATHLEN, format, &tm);
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2017-08-14 14:42:07 +02:00
|
|
|
static struct timespec file_calc_offset(const struct timespec *first, const struct timespec *epoch, enum epoch_mode mode)
|
2017-05-08 00:46:48 +02:00
|
|
|
{
|
|
|
|
/* Get current time */
|
|
|
|
struct timespec now = time_now();
|
|
|
|
struct timespec offset;
|
|
|
|
|
2017-08-14 14:42:07 +02:00
|
|
|
/* Set offset depending on epoch_mode */
|
2017-05-08 00:46:48 +02:00
|
|
|
switch (mode) {
|
2017-06-17 18:53:33 +02:00
|
|
|
case FILE_EPOCH_DIRECT: /* read first value at now + epoch */
|
2017-05-08 00:46:48 +02:00
|
|
|
offset = time_diff(first, &now);
|
2017-07-24 15:30:47 +02:00
|
|
|
return time_add(&offset, epoch);
|
2017-05-08 00:46:48 +02:00
|
|
|
|
2017-06-17 18:53:33 +02:00
|
|
|
case FILE_EPOCH_WAIT: /* read first value at now + first + epoch */
|
2017-05-08 00:46:48 +02:00
|
|
|
offset = now;
|
|
|
|
return time_add(&now, epoch);
|
|
|
|
|
2017-06-17 18:53:33 +02:00
|
|
|
case FILE_EPOCH_RELATIVE: /* read first value at first + epoch */
|
2017-05-08 00:46:48 +02:00
|
|
|
return *epoch;
|
|
|
|
|
2017-08-14 14:42:07 +02:00
|
|
|
case FILE_EPOCH_ABSOLUTE: /* read first value at f->epoch */
|
2017-05-08 00:46:48 +02:00
|
|
|
return time_diff(first, epoch);
|
|
|
|
|
2017-07-24 15:30:47 +02:00
|
|
|
default:
|
|
|
|
return (struct timespec) { 0 };
|
2017-05-08 00:46:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-03 00:19:27 +02:00
|
|
|
int file_parse(struct node *n, json_t *cfg)
|
2015-10-14 12:11:33 +02:00
|
|
|
{
|
2015-11-29 22:47:57 +01:00
|
|
|
struct file *f = n->_vd;
|
2017-05-05 19:24:16 +00:00
|
|
|
|
2017-08-03 00:19:27 +02:00
|
|
|
int ret;
|
|
|
|
json_error_t err;
|
|
|
|
|
2017-08-14 14:42:07 +02:00
|
|
|
const char *uri_tmpl = NULL;
|
2018-05-09 10:27:38 +02:00
|
|
|
const char *format = "villas.human";
|
2017-08-14 14:42:07 +02:00
|
|
|
const char *eof = NULL;
|
|
|
|
const char *epoch_mode = NULL;
|
|
|
|
double epoch_flt = 0;
|
|
|
|
|
|
|
|
/* Default values */
|
|
|
|
f->rate = 0;
|
|
|
|
f->eof = FILE_EOF_EXIT;
|
|
|
|
f->epoch_mode = FILE_EPOCH_DIRECT;
|
|
|
|
f->flush = 0;
|
|
|
|
|
2017-09-04 23:16:58 +02:00
|
|
|
ret = json_unpack_ex(cfg, &err, 0, "{ s: s, s?: b, s?: s, s?: F, s?: s, s?: F, s?: s }",
|
2017-08-14 14:42:07 +02:00
|
|
|
"uri", &uri_tmpl,
|
|
|
|
"flush", &f->flush,
|
|
|
|
"eof", &eof,
|
|
|
|
"rate", &f->rate,
|
|
|
|
"epoch_mode", &epoch_mode,
|
|
|
|
"epoch", &epoch_flt,
|
|
|
|
"format", &format
|
2017-08-03 00:19:27 +02:00
|
|
|
);
|
|
|
|
if (ret)
|
|
|
|
jerror(&err, "Failed to parse configuration of node %s", node_name(n));
|
2017-05-05 19:24:16 +00:00
|
|
|
|
2017-08-14 14:42:07 +02:00
|
|
|
f->epoch = time_from_double(epoch_flt);
|
|
|
|
f->uri_tmpl = uri_tmpl ? strdup(uri_tmpl) : NULL;
|
2017-09-04 14:28:55 +02:00
|
|
|
|
2018-05-12 13:56:12 +02:00
|
|
|
f->format = format_type_lookup(format);
|
2017-08-14 14:42:07 +02:00
|
|
|
if (!f->format)
|
|
|
|
error("Invalid format '%s' for node %s", format, node_name(n));
|
|
|
|
|
|
|
|
if (eof) {
|
|
|
|
if (!strcmp(eof, "exit"))
|
|
|
|
f->eof = FILE_EOF_EXIT;
|
|
|
|
else if (!strcmp(eof, "rewind"))
|
|
|
|
f->eof = FILE_EOF_REWIND;
|
|
|
|
else if (!strcmp(eof, "wait"))
|
|
|
|
f->eof = FILE_EOF_WAIT;
|
|
|
|
else
|
|
|
|
error("Invalid mode '%s' for 'eof' setting of node %s", eof, node_name(n));
|
2015-10-14 12:11:33 +02:00
|
|
|
}
|
|
|
|
|
2017-08-14 14:42:07 +02:00
|
|
|
if (epoch_mode) {
|
|
|
|
if (!strcmp(epoch_mode, "direct"))
|
|
|
|
f->epoch_mode = FILE_EPOCH_DIRECT;
|
|
|
|
else if (!strcmp(epoch_mode, "wait"))
|
|
|
|
f->epoch_mode = FILE_EPOCH_WAIT;
|
|
|
|
else if (!strcmp(epoch_mode, "relative"))
|
|
|
|
f->epoch_mode = FILE_EPOCH_RELATIVE;
|
|
|
|
else if (!strcmp(epoch_mode, "absolute"))
|
|
|
|
f->epoch_mode = FILE_EPOCH_ABSOLUTE;
|
|
|
|
else if (!strcmp(epoch_mode, "original"))
|
|
|
|
f->epoch_mode = FILE_EPOCH_ORIGINAL;
|
|
|
|
else
|
|
|
|
error("Invalid value '%s' for setting 'epoch_mode' of node %s", epoch_mode, node_name(n));
|
2015-10-14 12:11:33 +02:00
|
|
|
}
|
|
|
|
|
2015-11-29 22:47:57 +01:00
|
|
|
n->_vd = f;
|
2015-10-14 12:11:33 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-09-22 12:58:37 +02:00
|
|
|
char * file_print(struct node *n)
|
2015-03-31 13:28:11 +02:00
|
|
|
{
|
2017-10-18 15:39:53 +02:00
|
|
|
struct file *f = (struct file *) n->_vd;
|
2015-09-22 12:58:37 +02:00
|
|
|
char *buf = NULL;
|
2017-05-05 19:24:16 +00:00
|
|
|
|
2017-08-14 14:42:07 +02:00
|
|
|
const char *epoch_str = NULL;
|
|
|
|
const char *eof_str = NULL;
|
2017-05-05 19:24:16 +00:00
|
|
|
|
2017-08-14 14:42:07 +02:00
|
|
|
switch (f->epoch_mode) {
|
|
|
|
case FILE_EPOCH_DIRECT: epoch_str = "direct"; break;
|
|
|
|
case FILE_EPOCH_WAIT: epoch_str = "wait"; break;
|
|
|
|
case FILE_EPOCH_RELATIVE: epoch_str = "relative"; break;
|
|
|
|
case FILE_EPOCH_ABSOLUTE: epoch_str = "absolute"; break;
|
|
|
|
case FILE_EPOCH_ORIGINAL: epoch_str = "original"; break;
|
2015-10-09 13:08:39 +02:00
|
|
|
}
|
2017-05-05 19:24:16 +00:00
|
|
|
|
2017-08-14 14:42:07 +02:00
|
|
|
switch (f->eof) {
|
|
|
|
case FILE_EOF_EXIT: eof_str = "exit"; break;
|
|
|
|
case FILE_EOF_WAIT: eof_str = "wait"; break;
|
|
|
|
case FILE_EOF_REWIND: eof_str = "rewind"; break;
|
2015-10-09 13:08:39 +02:00
|
|
|
}
|
2017-05-05 19:24:16 +00:00
|
|
|
|
2017-08-14 14:42:07 +02:00
|
|
|
strcatf(&buf, "uri=%s, format=%s, flush=%s, eof=%s, epoch_mode=%s, epoch=%.2f",
|
|
|
|
f->uri ? f->uri : f->uri_tmpl,
|
|
|
|
plugin_name(f->format),
|
|
|
|
f->flush ? "yes" : "no",
|
|
|
|
eof_str,
|
|
|
|
epoch_str,
|
|
|
|
time_to_double(&f->epoch)
|
|
|
|
);
|
|
|
|
|
|
|
|
if (f->rate)
|
|
|
|
strcatf(&buf, ", rate=%.1f", f->rate);
|
|
|
|
|
|
|
|
if (f->first.tv_sec || f->first.tv_nsec)
|
|
|
|
strcatf(&buf, ", first=%.2f", time_to_double(&f->first));
|
2017-05-05 19:24:16 +00:00
|
|
|
|
2017-08-14 14:42:07 +02:00
|
|
|
if (f->offset.tv_sec || f->offset.tv_nsec)
|
|
|
|
strcatf(&buf, ", offset=%.2f", time_to_double(&f->offset));
|
2017-05-05 19:24:16 +00:00
|
|
|
|
2017-08-14 14:42:07 +02:00
|
|
|
if ((f->first.tv_sec || f->first.tv_nsec) &&
|
|
|
|
(f->offset.tv_sec || f->offset.tv_nsec)) {
|
2015-10-14 12:11:33 +02:00
|
|
|
struct timespec eta, now = time_now();
|
2015-10-09 13:08:39 +02:00
|
|
|
|
2017-08-14 14:42:07 +02:00
|
|
|
eta = time_add(&f->first, &f->offset);
|
2015-10-14 12:11:33 +02:00
|
|
|
eta = time_diff(&now, &eta);
|
2015-10-09 13:08:39 +02:00
|
|
|
|
|
|
|
if (eta.tv_sec || eta.tv_nsec)
|
2017-06-17 18:54:03 +02:00
|
|
|
strcatf(&buf, ", eta=%.2f sec", time_to_double(&eta));
|
2015-10-09 13:08:39 +02:00
|
|
|
}
|
2017-05-05 19:24:16 +00:00
|
|
|
|
2015-10-09 13:08:39 +02:00
|
|
|
return buf;
|
2015-03-31 13:28:11 +02:00
|
|
|
}
|
|
|
|
|
2017-03-11 23:30:24 -03:00
|
|
|
int file_start(struct node *n)
|
2015-03-31 13:28:11 +02:00
|
|
|
{
|
2017-10-18 15:39:53 +02:00
|
|
|
struct file *f = (struct file *) n->_vd;
|
2017-05-05 19:24:16 +00:00
|
|
|
|
2015-10-14 12:11:33 +02:00
|
|
|
struct timespec now = time_now();
|
2017-08-14 14:42:07 +02:00
|
|
|
int ret, flags;
|
2015-03-31 13:28:11 +02:00
|
|
|
|
2017-08-14 14:42:07 +02:00
|
|
|
/* Prepare file name */
|
|
|
|
f->uri = file_format_name(f->uri_tmpl, &now);
|
|
|
|
|
|
|
|
/* Open file */
|
2017-09-16 15:04:59 +02:00
|
|
|
flags = SAMPLE_HAS_ALL;
|
2017-08-14 14:42:07 +02:00
|
|
|
if (f->flush)
|
|
|
|
flags |= IO_FLUSH;
|
|
|
|
|
2018-05-12 15:25:29 +02:00
|
|
|
ret = io_init(&f->io, f->format, n, flags);
|
2017-08-14 14:42:07 +02:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
ret = io_open(&f->io, f->uri);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
/* Create timer */
|
2017-08-22 12:16:33 +02:00
|
|
|
ret = task_init(&f->task, f->rate, CLOCK_REALTIME);
|
2017-08-14 14:42:07 +02:00
|
|
|
if (ret)
|
|
|
|
serror("Failed to create timer");
|
|
|
|
|
|
|
|
/* Get timestamp of first line */
|
|
|
|
if (f->epoch_mode != FILE_EPOCH_ORIGINAL) {
|
|
|
|
io_rewind(&f->io);
|
|
|
|
|
2017-08-22 12:16:33 +02:00
|
|
|
struct sample s = { .capacity = 0 };
|
2017-08-14 14:42:07 +02:00
|
|
|
struct sample *smps[] = { &s };
|
2015-08-07 01:11:43 +02:00
|
|
|
|
2017-09-05 10:11:23 +02:00
|
|
|
if (io_eof(&f->io)) {
|
|
|
|
warn("Empty file");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ret = io_scan(&f->io, smps, 1);
|
|
|
|
if (ret == 1) {
|
|
|
|
f->first = s.ts.origin;
|
|
|
|
f->offset = file_calc_offset(&f->first, &f->epoch, f->epoch_mode);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
warn("Failed to read first timestamp of node %s", node_name(n));
|
|
|
|
}
|
2015-03-31 13:28:11 +02:00
|
|
|
}
|
2015-08-07 01:11:43 +02:00
|
|
|
|
2017-08-14 14:42:07 +02:00
|
|
|
io_rewind(&f->io);
|
|
|
|
|
2015-03-31 13:28:11 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-03-11 23:30:24 -03:00
|
|
|
int file_stop(struct node *n)
|
2015-03-31 13:28:11 +02:00
|
|
|
{
|
2017-08-14 14:42:07 +02:00
|
|
|
int ret;
|
2018-05-12 18:03:40 +02:00
|
|
|
struct file *f = (struct file *) n->_vd;
|
2017-05-05 19:24:16 +00:00
|
|
|
|
2018-05-12 18:03:40 +02:00
|
|
|
ret = task_destroy(&f->task);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2015-08-07 01:11:43 +02:00
|
|
|
|
2017-08-14 14:42:07 +02:00
|
|
|
ret = io_close(&f->io);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2018-05-12 18:03:40 +02:00
|
|
|
free(f->uri);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int file_destroy(struct node *n)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct file *f = (struct file *) n->_vd;
|
|
|
|
|
2017-08-14 14:42:07 +02:00
|
|
|
ret = io_destroy(&f->io);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2015-03-31 13:28:11 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-07-11 18:14:29 +02:00
|
|
|
int file_read(struct node *n, struct sample *smps[], unsigned cnt, unsigned *release)
|
2015-03-31 13:28:11 +02:00
|
|
|
{
|
2017-10-18 15:39:53 +02:00
|
|
|
struct file *f = (struct file *) n->_vd;
|
2017-08-14 14:42:07 +02:00
|
|
|
int ret;
|
|
|
|
uint64_t steps;
|
2016-06-08 22:39:43 +02:00
|
|
|
|
2018-07-11 18:14:29 +02:00
|
|
|
assert(cnt == 1);
|
2016-06-08 22:39:43 +02:00
|
|
|
|
2018-07-11 18:14:29 +02:00
|
|
|
retry: ret = io_scan(&f->io, smps, cnt);
|
2017-08-14 14:42:07 +02:00
|
|
|
if (ret <= 0) {
|
|
|
|
if (io_eof(&f->io)) {
|
|
|
|
switch (f->eof) {
|
2017-06-17 18:53:00 +02:00
|
|
|
case FILE_EOF_REWIND:
|
|
|
|
info("Rewind input file of node %s", node_name(n));
|
|
|
|
|
2017-08-14 14:42:07 +02:00
|
|
|
f->offset = file_calc_offset(&f->first, &f->epoch, f->epoch_mode);
|
|
|
|
io_rewind(&f->io);
|
2017-06-17 18:53:00 +02:00
|
|
|
goto retry;
|
2017-07-24 19:33:35 +02:00
|
|
|
|
2017-06-17 18:53:00 +02:00
|
|
|
case FILE_EOF_WAIT:
|
2017-08-14 14:42:07 +02:00
|
|
|
/* We wait 10ms before fetching again. */
|
|
|
|
usleep(100000);
|
|
|
|
|
|
|
|
/* Try to download more data if this is a remote file. */
|
|
|
|
if (f->io.mode == IO_MODE_ADVIO)
|
2018-05-12 10:41:40 +02:00
|
|
|
adownload(f->io.input.stream.adv, 1);
|
2017-08-14 14:42:07 +02:00
|
|
|
|
2017-06-17 18:53:00 +02:00
|
|
|
goto retry;
|
2017-07-24 19:33:35 +02:00
|
|
|
|
2017-06-17 18:53:00 +02:00
|
|
|
case FILE_EOF_EXIT:
|
2017-07-06 21:14:42 +02:00
|
|
|
info("Reached end-of-file of node %s", node_name(n));
|
2017-08-14 14:42:07 +02:00
|
|
|
|
2017-07-06 21:14:42 +02:00
|
|
|
killme(SIGTERM);
|
2017-07-12 00:58:37 +02:00
|
|
|
pause();
|
2017-03-29 20:14:01 +02:00
|
|
|
}
|
2015-08-09 23:52:44 +02:00
|
|
|
}
|
2016-06-08 22:39:43 +02:00
|
|
|
else
|
2017-08-14 14:42:07 +02:00
|
|
|
warn("Failed to read messages from node %s: reason=%d", node_name(n), ret);
|
2016-06-08 22:39:43 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2017-05-05 19:24:16 +00:00
|
|
|
|
2017-08-14 14:42:07 +02:00
|
|
|
/* We dont wait in FILE_EPOCH_ORIGINAL mode */
|
|
|
|
if (f->epoch_mode == FILE_EPOCH_ORIGINAL)
|
2018-07-11 18:14:29 +02:00
|
|
|
return cnt;
|
2017-07-24 19:33:35 +02:00
|
|
|
|
2017-08-14 14:42:07 +02:00
|
|
|
if (f->rate) {
|
2017-09-16 15:33:01 +02:00
|
|
|
steps = task_wait(&f->task);
|
2017-05-08 00:46:48 +02:00
|
|
|
|
2017-08-14 14:42:07 +02:00
|
|
|
smps[0]->ts.origin = time_now();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
smps[0]->ts.origin = time_add(&smps[0]->ts.origin, &f->offset);
|
2017-05-05 19:24:16 +00:00
|
|
|
|
2017-09-16 15:33:01 +02:00
|
|
|
task_set_next(&f->task, &smps[0]->ts.origin);
|
|
|
|
steps = task_wait(&f->task);
|
2015-05-06 11:49:13 +02:00
|
|
|
}
|
2015-08-07 01:11:43 +02:00
|
|
|
|
2017-08-14 14:42:07 +02:00
|
|
|
/* Check for overruns */
|
|
|
|
if (steps == 0)
|
|
|
|
serror("Failed to wait for timer");
|
|
|
|
else if (steps != 1)
|
|
|
|
warn("Missed steps: %" PRIu64, steps - 1);
|
|
|
|
|
2018-07-11 18:14:29 +02:00
|
|
|
return cnt;
|
2015-03-31 13:28:11 +02:00
|
|
|
}
|
|
|
|
|
2018-07-11 18:14:29 +02:00
|
|
|
int file_write(struct node *n, struct sample *smps[], unsigned cnt, unsigned *release)
|
2015-03-31 13:28:11 +02:00
|
|
|
{
|
2017-10-18 15:39:53 +02:00
|
|
|
struct file *f = (struct file *) n->_vd;
|
2015-08-07 01:11:43 +02:00
|
|
|
|
2018-07-11 18:14:29 +02:00
|
|
|
assert(cnt == 1);
|
2016-01-14 22:59:57 +01:00
|
|
|
|
2018-07-11 18:14:29 +02:00
|
|
|
io_print(&f->io, smps, cnt);
|
2015-08-07 01:11:43 +02:00
|
|
|
|
2018-07-11 18:14:29 +02:00
|
|
|
return cnt;
|
2015-08-07 01:11:43 +02:00
|
|
|
}
|
2015-09-19 15:26:30 +02:00
|
|
|
|
2017-08-30 00:25:42 +02:00
|
|
|
int file_fd(struct node *n)
|
|
|
|
{
|
2017-10-18 15:39:53 +02:00
|
|
|
struct file *f = (struct file *) n->_vd;
|
2017-09-04 14:28:55 +02:00
|
|
|
|
2017-08-30 00:25:42 +02:00
|
|
|
if (f->rate)
|
|
|
|
return task_fd(&f->task);
|
|
|
|
else {
|
|
|
|
if (f->epoch_mode == FILE_EPOCH_ORIGINAL)
|
|
|
|
return io_fd(&f->io);
|
|
|
|
else
|
|
|
|
return -1; /** @todo not supported yet */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-12 14:35:05 -03:00
|
|
|
static struct plugin p = {
|
2015-11-23 16:44:01 +01:00
|
|
|
.name = "file",
|
|
|
|
.description = "support for file log / replay node type",
|
2017-02-12 14:35:05 -03:00
|
|
|
.type = PLUGIN_TYPE_NODE,
|
|
|
|
.node = {
|
|
|
|
.vectorize = 1,
|
|
|
|
.size = sizeof(struct file),
|
|
|
|
.parse = file_parse,
|
|
|
|
.print = file_print,
|
2017-03-11 23:30:24 -03:00
|
|
|
.start = file_start,
|
|
|
|
.stop = file_stop,
|
2018-05-12 18:03:40 +02:00
|
|
|
.destroy = file_destroy,
|
2017-02-12 14:35:05 -03:00
|
|
|
.read = file_read,
|
2017-08-30 00:25:42 +02:00
|
|
|
.write = file_write,
|
|
|
|
.fd = file_fd
|
2017-02-12 14:35:05 -03:00
|
|
|
}
|
2015-11-23 16:44:01 +01:00
|
|
|
};
|
|
|
|
|
2017-07-02 23:53:48 +02:00
|
|
|
REGISTER_PLUGIN(&p)
|
2017-07-07 11:27:03 +02:00
|
|
|
LIST_INIT_STATIC(&p.node.instances)
|