X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Finput%2Fcsv.c;h=a8c689443a35430712b05a0099434d7c386e6031;hb=b75dc14a9410f57b3f7853854da013af86fb87c2;hp=0a2d7276d996eb14b5f0310999feb1ed2e3c8c06;hpb=6433156c3275df933e4bf6dcfb020c91fca0ae86;p=libsigrok.git
diff --git a/src/input/csv.c b/src/input/csv.c
index 0a2d7276..a8c68944 100644
--- a/src/input/csv.c
+++ b/src/input/csv.c
@@ -17,6 +17,7 @@
* along with this program. If not, see .
*/
+#include
#include
#include
#include
@@ -132,17 +133,6 @@ struct context {
size_t line_number;
};
-static int format_match(GHashTable *metadata)
-{
- char *buf;
-
- buf = g_hash_table_lookup(metadata, GINT_TO_POINTER(SR_INPUT_META_MIMETYPE));
- if (!strcmp(buf, "text/csv"))
- return SR_OK;
-
- return SR_ERR;
-}
-
static void strip_comment(char *buf, const GString *prefix)
{
char *ptr;
@@ -631,6 +621,7 @@ static int process_buffer(struct sr_input *in)
src = sr_config_new(SR_CONF_SAMPLERATE, g_variant_new_uint64(samplerate));
meta.config = g_slist_append(NULL, src);
sr_session_send(in->sdi, &packet);
+ g_slist_free(meta.config);
sr_config_free(src);
}
@@ -747,7 +738,6 @@ static int receive(struct sr_input *in, GString *buf)
static int end(struct sr_input *in)
{
struct context *inc;
- struct sr_datafeed_packet packet;
int ret;
if (in->sdi_ready)
@@ -756,11 +746,8 @@ static int end(struct sr_input *in)
ret = SR_OK;
inc = in->priv;
- if (inc->started) {
- /* End of stream. */
- packet.type = SR_DF_END;
- sr_session_send(in->sdi, &packet);
- }
+ if (inc->started)
+ std_session_send_df_end(in->sdi, LOG_PREFIX);
return ret;
}
@@ -781,6 +768,17 @@ static void cleanup(struct sr_input *in)
g_free(inc->sample_buffer);
}
+static int reset(struct sr_input *in)
+{
+ struct context *inc = in->priv;
+
+ cleanup(in);
+ inc->started = FALSE;
+ g_string_truncate(in->buf, 0);
+
+ return SR_OK;
+}
+
static struct sr_option options[] = {
{ "single-column", "Single column", "Enable/specify single column", NULL, NULL },
{ "numchannels", "Max channels", "Number of channels", NULL, NULL },
@@ -794,7 +792,7 @@ static struct sr_option options[] = {
ALL_ZERO
};
-static struct sr_option *get_options(void)
+static const struct sr_option *get_options(void)
{
if (!options[0].def) {
options[0].def = g_variant_ref_sink(g_variant_new_int32(0));
@@ -816,11 +814,10 @@ SR_PRIV struct sr_input_module input_csv = {
.name = "CSV",
.desc = "Comma-separated values",
.exts = (const char*[]){"csv", NULL},
- .metadata = { SR_INPUT_META_MIMETYPE },
.options = get_options,
- .format_match = format_match,
.init = init,
.receive = receive,
.end = end,
.cleanup = cleanup,
+ .reset = reset,
};