sr: out: Use uint8_t (not char) for buffers.

This commit is contained in:
Uwe Hermann 2012-03-28 20:00:13 +02:00
parent 69cfcfc8f0
commit 054e670906
15 changed files with 100 additions and 91 deletions

View File

@ -74,8 +74,8 @@
* out_unitsize, data_out, and length_out are undefined. * out_unitsize, data_out, and length_out are undefined.
*/ */
SR_API int sr_filter_probes(int in_unitsize, int out_unitsize, SR_API int sr_filter_probes(int in_unitsize, int out_unitsize,
const int *probelist, const unsigned char *data_in, const int *probelist, const uint8_t *data_in,
uint64_t length_in, char **data_out, uint64_t length_in, uint8_t **data_out,
uint64_t *length_out) uint64_t *length_out)
{ {
unsigned int in_offset, out_offset; unsigned int in_offset, out_offset;

View File

@ -42,7 +42,7 @@ struct context {
int line_offset; int line_offset;
int linebuf_len; int linebuf_len;
char *probelist[SR_MAX_NUM_PROBES + 1]; char *probelist[SR_MAX_NUM_PROBES + 1];
char *linebuf; uint8_t *linebuf;
int spl_cnt; int spl_cnt;
uint8_t *linevalues; uint8_t *linevalues;
char *header; char *header;
@ -51,7 +51,7 @@ struct context {
enum outputmode mode; enum outputmode mode;
}; };
static void flush_linebufs(struct context *ctx, char *outbuf) static void flush_linebufs(struct context *ctx, uint8_t *outbuf)
{ {
static int max_probename_len = 0; static int max_probename_len = 0;
int len, i; int len, i;
@ -168,12 +168,12 @@ static int init(struct sr_output *o, int default_spl, enum outputmode mode)
return SR_OK; return SR_OK;
} }
static int event(struct sr_output *o, int event_type, char **data_out, static int event(struct sr_output *o, int event_type, uint8_t **data_out,
uint64_t *length_out) uint64_t *length_out)
{ {
struct context *ctx; struct context *ctx;
int outsize; int outsize;
char *outbuf; uint8_t *outbuf;
ctx = o->internal; ctx = o->internal;
switch (event_type) { switch (event_type) {
@ -210,14 +210,15 @@ static int init_bits(struct sr_output *o)
return init(o, DEFAULT_BPL_BITS, MODE_BITS); return init(o, DEFAULT_BPL_BITS, MODE_BITS);
} }
static int data_bits(struct sr_output *o, const char *data_in, static int data_bits(struct sr_output *o, const uint8_t *data_in,
uint64_t length_in, char **data_out, uint64_t *length_out) uint64_t length_in, uint8_t **data_out,
uint64_t *length_out)
{ {
struct context *ctx; struct context *ctx;
unsigned int outsize, offset, p; unsigned int outsize, offset, p;
int max_linelen; int max_linelen;
struct sr_analog_sample *sample; struct sr_analog_sample *sample;
char *outbuf, c; uint8_t *outbuf, c;
ctx = o->internal; ctx = o->internal;
max_linelen = SR_MAX_PROBENAME_LEN + 3 + ctx->samples_per_line max_linelen = SR_MAX_PROBENAME_LEN + 3 + ctx->samples_per_line
@ -299,14 +300,15 @@ static int init_hex(struct sr_output *o)
return init(o, DEFAULT_BPL_HEX, MODE_HEX); return init(o, DEFAULT_BPL_HEX, MODE_HEX);
} }
static int data_hex(struct sr_output *o, const char *data_in, static int data_hex(struct sr_output *o, const uint8_t *data_in,
uint64_t length_in, char **data_out, uint64_t *length_out) uint64_t length_in, uint8_t **data_out,
uint64_t *length_out)
{ {
struct context *ctx; struct context *ctx;
unsigned int outsize, offset, p; unsigned int outsize, offset, p;
int max_linelen; int max_linelen;
uint64_t sample; uint64_t sample;
char *outbuf; uint8_t *outbuf;
ctx = o->internal; ctx = o->internal;
max_linelen = SR_MAX_PROBENAME_LEN + 3 + ctx->samples_per_line max_linelen = SR_MAX_PROBENAME_LEN + 3 + ctx->samples_per_line
@ -366,14 +368,15 @@ static int init_ascii(struct sr_output *o)
return init(o, DEFAULT_BPL_ASCII, MODE_ASCII); return init(o, DEFAULT_BPL_ASCII, MODE_ASCII);
} }
static int data_ascii(struct sr_output *o, const char *data_in, static int data_ascii(struct sr_output *o, const uint8_t *data_in,
uint64_t length_in, char **data_out, uint64_t *length_out) uint64_t length_in, uint8_t **data_out,
uint64_t *length_out)
{ {
struct context *ctx; struct context *ctx;
unsigned int outsize, offset, p; unsigned int outsize, offset, p;
int max_linelen; int max_linelen;
uint64_t sample; uint64_t sample;
char *outbuf; uint8_t *outbuf;
ctx = o->internal; ctx = o->internal;
max_linelen = SR_MAX_PROBENAME_LEN + 3 + ctx->samples_per_line max_linelen = SR_MAX_PROBENAME_LEN + 3 + ctx->samples_per_line

View File

@ -24,10 +24,10 @@
#include "sigrok.h" #include "sigrok.h"
#include "sigrok-internal.h" #include "sigrok-internal.h"
static int data(struct sr_output *o, const char *data_in, uint64_t length_in, static int data(struct sr_output *o, const uint8_t *data_in,
char **data_out, uint64_t *length_out) uint64_t length_in, uint8_t **data_out, uint64_t *length_out)
{ {
char *outbuf; uint8_t *outbuf;
/* Prevent compiler warnings. */ /* Prevent compiler warnings. */
(void)o; (void)o;

View File

@ -133,11 +133,11 @@ static int init(struct sr_output *o)
return 0; /* TODO: SR_OK? */ return 0; /* TODO: SR_OK? */
} }
static int event(struct sr_output *o, int event_type, char **data_out, static int event(struct sr_output *o, int event_type, uint8_t **data_out,
uint64_t *length_out) uint64_t *length_out)
{ {
struct context *ctx; struct context *ctx;
char *outbuf; uint8_t *outbuf;
if (!o) { if (!o) {
sr_warn("la8 out: %s: o was NULL", __func__); sr_warn("la8 out: %s: o was NULL", __func__);
@ -196,11 +196,11 @@ static int event(struct sr_output *o, int event_type, char **data_out,
return SR_OK; return SR_OK;
} }
static int data(struct sr_output *o, const char *data_in, uint64_t length_in, static int data(struct sr_output *o, const uint8_t *data_in,
char **data_out, uint64_t *length_out) uint64_t length_in, uint8_t **data_out, uint64_t *length_out)
{ {
struct context *ctx; struct context *ctx;
char *outbuf; uint8_t *outbuf;
if (!o) { if (!o) {
sr_warn("la8 out: %s: o was NULL", __func__); sr_warn("la8 out: %s: o was NULL", __func__);

View File

@ -122,7 +122,7 @@ static int init(struct sr_output *o)
return 0; /* TODO: SR_OK? */ return 0; /* TODO: SR_OK? */
} }
static int event(struct sr_output *o, int event_type, char **data_out, static int event(struct sr_output *o, int event_type, uint8_t **data_out,
uint64_t *length_out) uint64_t *length_out)
{ {
struct context *ctx; struct context *ctx;
@ -168,8 +168,8 @@ static int event(struct sr_output *o, int event_type, char **data_out,
return SR_OK; return SR_OK;
} }
static int data(struct sr_output *o, const char *data_in, uint64_t length_in, static int data(struct sr_output *o, const uint8_t *data_in,
char **data_out, uint64_t *length_out) uint64_t length_in, uint8_t **data_out, uint64_t *length_out)
{ {
struct context *ctx; struct context *ctx;
GString *outstr; GString *outstr;
@ -209,7 +209,7 @@ static int data(struct sr_output *o, const char *data_in, uint64_t length_in,
g_string_append_printf(outstr, "\n"); g_string_append_printf(outstr, "\n");
} }
*data_out = outstr->str; *data_out = (uint8_t *)outstr->str;
*length_out = outstr->len; *length_out = outstr->len;
g_string_free(outstr, FALSE); g_string_free(outstr, FALSE);

View File

@ -118,7 +118,7 @@ static int init(struct sr_output *o)
/* Columns / channels */ /* Columns / channels */
wbuf[0] = '\0'; wbuf[0] = '\0';
for (i = 0; i < ctx->num_enabled_probes; i++) { for (i = 0; i < ctx->num_enabled_probes; i++) {
c = (char *)&wbuf + strlen((char *)&wbuf); c = (char *)&wbuf + strlen((const char *)&wbuf);
sprintf(c, "# %d\t\t%s\n", i + 1, ctx->probelist[i]); sprintf(c, "# %d\t\t%s\n", i + 1, ctx->probelist[i]);
} }
@ -145,7 +145,7 @@ static int init(struct sr_output *o)
return 0; return 0;
} }
static int event(struct sr_output *o, int event_type, char **data_out, static int event(struct sr_output *o, int event_type, uint8_t **data_out,
uint64_t *length_out) uint64_t *length_out)
{ {
if (!o) { if (!o) {
@ -183,14 +183,14 @@ static int event(struct sr_output *o, int event_type, char **data_out,
return SR_OK; return SR_OK;
} }
static int data(struct sr_output *o, const char *data_in, uint64_t length_in, static int data(struct sr_output *o, const uint8_t *data_in,
char **data_out, uint64_t *length_out) uint64_t length_in, uint8_t **data_out, uint64_t *length_out)
{ {
struct context *ctx; struct context *ctx;
unsigned int max_linelen, outsize, p, curbit, i; unsigned int max_linelen, outsize, p, curbit, i;
uint64_t sample; uint64_t sample;
static uint64_t samplecount = 0, old_sample = 0; static uint64_t samplecount = 0, old_sample = 0;
char *outbuf, *c; uint8_t *outbuf, *c;
if (!o) { if (!o) {
sr_err("gnuplot out: %s: o was NULL", __func__); sr_err("gnuplot out: %s: o was NULL", __func__);
@ -231,7 +231,7 @@ static int data(struct sr_output *o, const char *data_in, uint64_t length_in,
outbuf[0] = '\0'; outbuf[0] = '\0';
if (ctx->header) { if (ctx->header) {
/* The header is still here, this must be the first packet. */ /* The header is still here, this must be the first packet. */
strncpy(outbuf, ctx->header, outsize); strncpy((char *)outbuf, ctx->header, outsize);
g_free(ctx->header); g_free(ctx->header);
ctx->header = NULL; ctx->header = NULL;
} }
@ -251,22 +251,22 @@ static int data(struct sr_output *o, const char *data_in, uint64_t length_in,
old_sample = sample; old_sample = sample;
/* The first column is a counter (needed for gnuplot). */ /* The first column is a counter (needed for gnuplot). */
c = outbuf + strlen(outbuf); c = outbuf + strlen((const char *)outbuf);
sprintf(c, "%" PRIu64 "\t", samplecount++); sprintf((char *)c, "%" PRIu64 "\t", samplecount++);
/* The next columns are the values of all channels. */ /* The next columns are the values of all channels. */
for (p = 0; p < ctx->num_enabled_probes; p++) { for (p = 0; p < ctx->num_enabled_probes; p++) {
curbit = (sample & ((uint64_t) (1 << p))) >> p; curbit = (sample & ((uint64_t) (1 << p))) >> p;
c = outbuf + strlen(outbuf); c = outbuf + strlen((const char *)outbuf);
sprintf(c, "%d ", curbit); sprintf((char *)c, "%d ", curbit);
} }
c = outbuf + strlen(outbuf); c = outbuf + strlen((const char *)outbuf);
sprintf(c, "\n"); sprintf((char *)c, "\n");
} }
*data_out = outbuf; *data_out = outbuf;
*length_out = strlen(outbuf); *length_out = strlen((const char *)outbuf);
return SR_OK; return SR_OK;
} }
@ -360,14 +360,15 @@ static int analog_init(struct sr_output *o)
return 0; return 0;
} }
static int analog_data(struct sr_output *o, char *data_in, uint64_t length_in, static int analog_data(struct sr_output *o, uint8_t *data_in,
char **data_out, uint64_t *length_out) uint64_t length_in, uint8_t **data_out,
uint64_t *length_out)
{ {
struct context *ctx; struct context *ctx;
unsigned int max_linelen, outsize, p, /* curbit, */ i; unsigned int max_linelen, outsize, p, /* curbit, */ i;
// uint64_t sample; // uint64_t sample;
static uint64_t samplecount = 0; static uint64_t samplecount = 0;
char *outbuf, *c; uint8_t *outbuf, *c;
struct sr_analog_sample *sample; struct sr_analog_sample *sample;
ctx = o->internal; ctx = o->internal;

View File

@ -76,7 +76,7 @@ static int init(struct sr_output *o)
return SR_OK; return SR_OK;
} }
static int event(struct sr_output *o, int event_type, char **data_out, static int event(struct sr_output *o, int event_type, uint8_t **data_out,
uint64_t *length_out) uint64_t *length_out)
{ {
struct context *ctx; struct context *ctx;
@ -95,8 +95,8 @@ static int event(struct sr_output *o, int event_type, char **data_out,
return SR_OK; return SR_OK;
} }
static int data(struct sr_output *o, const char *data_in, uint64_t length_in, static int data(struct sr_output *o, const uint8_t *data_in,
char **data_out, uint64_t *length_out) uint64_t length_in, uint8_t **data_out, uint64_t *length_out)
{ {
GString *out; GString *out;
struct context *ctx; struct context *ctx;
@ -117,7 +117,7 @@ static int data(struct sr_output *o, const char *data_in, uint64_t length_in,
g_string_append_printf(out, "%08x@%"PRIu64"\n", g_string_append_printf(out, "%08x@%"PRIu64"\n",
(uint32_t) sample, ctx->num_samples++); (uint32_t) sample, ctx->num_samples++);
} }
*data_out = out->str; *data_out = (uint8_t *)out->str;
*length_out = out->len; *length_out = out->len;
g_string_free(out, FALSE); g_string_free(out, FALSE);

View File

@ -30,15 +30,15 @@ SR_PRIV int init_ascii(struct sr_output *o)
return init(o, DEFAULT_BPL_ASCII, MODE_ASCII); return init(o, DEFAULT_BPL_ASCII, MODE_ASCII);
} }
SR_PRIV int data_ascii(struct sr_output *o, const char *data_in, SR_PRIV int data_ascii(struct sr_output *o, const uint8_t *data_in,
uint64_t length_in, char **data_out, uint64_t length_in, uint8_t **data_out,
uint64_t *length_out) uint64_t *length_out)
{ {
struct context *ctx; struct context *ctx;
unsigned int outsize, offset, p; unsigned int outsize, offset, p;
int max_linelen; int max_linelen;
uint64_t sample; uint64_t sample;
char *outbuf; uint8_t *outbuf;
ctx = o->internal; ctx = o->internal;
max_linelen = SR_MAX_PROBENAME_LEN + 3 + ctx->samples_per_line max_linelen = SR_MAX_PROBENAME_LEN + 3 + ctx->samples_per_line
@ -58,7 +58,7 @@ SR_PRIV int data_ascii(struct sr_output *o, const char *data_in,
outbuf[0] = '\0'; outbuf[0] = '\0';
if (ctx->header) { if (ctx->header) {
/* The header is still here, this must be the first packet. */ /* The header is still here, this must be the first packet. */
strncpy(outbuf, ctx->header, outsize); strncpy((char *)outbuf, ctx->header, outsize);
g_free(ctx->header); g_free(ctx->header);
ctx->header = NULL; ctx->header = NULL;
} }
@ -113,7 +113,7 @@ SR_PRIV int data_ascii(struct sr_output *o, const char *data_in,
} }
*data_out = outbuf; *data_out = outbuf;
*length_out = strlen(outbuf); *length_out = strlen((const char *)outbuf);
return SR_OK; return SR_OK;
} }

View File

@ -30,14 +30,15 @@ SR_PRIV int init_bits(struct sr_output *o)
return init(o, DEFAULT_BPL_BITS, MODE_BITS); return init(o, DEFAULT_BPL_BITS, MODE_BITS);
} }
SR_PRIV int data_bits(struct sr_output *o, const char *data_in, SR_PRIV int data_bits(struct sr_output *o, const uint8_t *data_in,
uint64_t length_in, char **data_out, uint64_t *length_out) uint64_t length_in, uint8_t **data_out,
uint64_t *length_out)
{ {
struct context *ctx; struct context *ctx;
unsigned int outsize, offset, p; unsigned int outsize, offset, p;
int max_linelen; int max_linelen;
uint64_t sample; uint64_t sample;
char *outbuf, c; uint8_t *outbuf, c;
ctx = o->internal; ctx = o->internal;
max_linelen = SR_MAX_PROBENAME_LEN + 3 + ctx->samples_per_line max_linelen = SR_MAX_PROBENAME_LEN + 3 + ctx->samples_per_line
@ -57,7 +58,7 @@ SR_PRIV int data_bits(struct sr_output *o, const char *data_in,
outbuf[0] = '\0'; outbuf[0] = '\0';
if (ctx->header) { if (ctx->header) {
/* The header is still here, this must be the first packet. */ /* The header is still here, this must be the first packet. */
strncpy(outbuf, ctx->header, outsize); strncpy((char *)outbuf, ctx->header, outsize);
g_free(ctx->header); g_free(ctx->header);
ctx->header = NULL; ctx->header = NULL;
@ -99,7 +100,7 @@ SR_PRIV int data_bits(struct sr_output *o, const char *data_in,
} }
*data_out = outbuf; *data_out = outbuf;
*length_out = strlen(outbuf); *length_out = strlen((const char *)outbuf);
return SR_OK; return SR_OK;
} }

View File

@ -30,14 +30,15 @@ SR_PRIV int init_hex(struct sr_output *o)
return init(o, DEFAULT_BPL_HEX, MODE_HEX); return init(o, DEFAULT_BPL_HEX, MODE_HEX);
} }
SR_PRIV int data_hex(struct sr_output *o, const char *data_in, SR_PRIV int data_hex(struct sr_output *o, const uint8_t *data_in,
uint64_t length_in, char **data_out, uint64_t *length_out) uint64_t length_in, uint8_t **data_out,
uint64_t *length_out)
{ {
struct context *ctx; struct context *ctx;
unsigned int outsize, offset, p; unsigned int outsize, offset, p;
int max_linelen; int max_linelen;
uint64_t sample; uint64_t sample;
char *outbuf; uint8_t *outbuf;
ctx = o->internal; ctx = o->internal;
max_linelen = SR_MAX_PROBENAME_LEN + 3 + ctx->samples_per_line max_linelen = SR_MAX_PROBENAME_LEN + 3 + ctx->samples_per_line
@ -53,7 +54,7 @@ SR_PRIV int data_hex(struct sr_output *o, const char *data_in,
outbuf[0] = '\0'; outbuf[0] = '\0';
if (ctx->header) { if (ctx->header) {
/* The header is still here, this must be the first packet. */ /* The header is still here, this must be the first packet. */
strncpy(outbuf, ctx->header, outsize); strncpy((char *)outbuf, ctx->header, outsize);
g_free(ctx->header); g_free(ctx->header);
ctx->header = NULL; ctx->header = NULL;
} }
@ -66,7 +67,7 @@ SR_PRIV int data_hex(struct sr_output *o, const char *data_in,
ctx->linevalues[p] <<= 1; ctx->linevalues[p] <<= 1;
if (sample & ((uint64_t) 1 << p)) if (sample & ((uint64_t) 1 << p))
ctx->linevalues[p] |= 1; ctx->linevalues[p] |= 1;
sprintf(ctx->linebuf + (p * ctx->linebuf_len) + sprintf((char *)ctx->linebuf + (p * ctx->linebuf_len) +
ctx->line_offset, "%.2x", ctx->linevalues[p]); ctx->line_offset, "%.2x", ctx->linevalues[p]);
} }
ctx->spl_cnt++; ctx->spl_cnt++;
@ -87,7 +88,7 @@ SR_PRIV int data_hex(struct sr_output *o, const char *data_in,
} }
*data_out = outbuf; *data_out = outbuf;
*length_out = strlen(outbuf); *length_out = strlen((const char *)outbuf);
return SR_OK; return SR_OK;
} }

View File

@ -27,7 +27,7 @@
#include "sigrok-internal.h" #include "sigrok-internal.h"
#include "text.h" #include "text.h"
SR_PRIV void flush_linebufs(struct context *ctx, char *outbuf) SR_PRIV void flush_linebufs(struct context *ctx, uint8_t *outbuf)
{ {
static int max_probename_len = 0; static int max_probename_len = 0;
int len, i; int len, i;
@ -45,7 +45,8 @@ SR_PRIV void flush_linebufs(struct context *ctx, char *outbuf)
} }
for (i = 0; ctx->probelist[i]; i++) { for (i = 0; ctx->probelist[i]; i++) {
sprintf(outbuf + strlen(outbuf), "%*s:%s\n", max_probename_len, sprintf((char *)outbuf + strlen((const char *)outbuf),
"%*s:%s\n", max_probename_len,
ctx->probelist[i], ctx->linebuf + i * ctx->linebuf_len); ctx->probelist[i], ctx->linebuf + i * ctx->linebuf_len);
} }
@ -57,8 +58,8 @@ SR_PRIV void flush_linebufs(struct context *ctx, char *outbuf)
if (ctx->mode == MODE_ASCII) if (ctx->mode == MODE_ASCII)
space_offset = 0; space_offset = 0;
sprintf(outbuf + strlen(outbuf), "T:%*s^\n", sprintf((char *)outbuf + strlen((const char *)outbuf),
ctx->mark_trigger + space_offset, ""); "T:%*s^\n", ctx->mark_trigger + space_offset, "");
} }
memset(ctx->linebuf, 0, i * ctx->linebuf_len); memset(ctx->linebuf, 0, i * ctx->linebuf_len);
@ -142,12 +143,12 @@ SR_PRIV int init(struct sr_output *o, int default_spl, enum outputmode mode)
return SR_OK; return SR_OK;
} }
SR_PRIV int event(struct sr_output *o, int event_type, char **data_out, SR_PRIV int event(struct sr_output *o, int event_type, uint8_t **data_out,
uint64_t *length_out) uint64_t *length_out)
{ {
struct context *ctx; struct context *ctx;
int outsize; int outsize;
char *outbuf; uint8_t *outbuf;
ctx = o->internal; ctx = o->internal;
switch (event_type) { switch (event_type) {
@ -165,7 +166,7 @@ SR_PRIV int event(struct sr_output *o, int event_type, char **data_out,
} }
flush_linebufs(ctx, outbuf); flush_linebufs(ctx, outbuf);
*data_out = outbuf; *data_out = outbuf;
*length_out = strlen(outbuf); *length_out = strlen((const char *)outbuf);
g_free(o->internal); g_free(o->internal);
o->internal = NULL; o->internal = NULL;
break; break;

View File

@ -37,7 +37,7 @@ struct context {
int line_offset; int line_offset;
int linebuf_len; int linebuf_len;
char *probelist[SR_MAX_NUM_PROBES + 1]; char *probelist[SR_MAX_NUM_PROBES + 1];
char *linebuf; uint8_t *linebuf;
int spl_cnt; int spl_cnt;
uint8_t *linevalues; uint8_t *linevalues;
char *header; char *header;
@ -46,23 +46,24 @@ struct context {
enum outputmode mode; enum outputmode mode;
}; };
SR_PRIV void flush_linebufs(struct context *ctx, char *outbuf); SR_PRIV void flush_linebufs(struct context *ctx, uint8_t *outbuf);
SR_PRIV int init(struct sr_output *o, int default_spl, enum outputmode mode); SR_PRIV int init(struct sr_output *o, int default_spl, enum outputmode mode);
SR_PRIV int event(struct sr_output *o, int event_type, char **data_out, SR_PRIV int event(struct sr_output *o, int event_type, uint8_t **data_out,
uint64_t *length_out); uint64_t *length_out);
SR_PRIV int init_bits(struct sr_output *o); SR_PRIV int init_bits(struct sr_output *o);
SR_PRIV int data_bits(struct sr_output *o, const char *data_in, SR_PRIV int data_bits(struct sr_output *o, const uint8_t *data_in,
uint64_t length_in, char **data_out, uint64_t length_in, uint8_t **data_out,
uint64_t *length_out); uint64_t *length_out);
SR_PRIV int init_hex(struct sr_output *o); SR_PRIV int init_hex(struct sr_output *o);
SR_PRIV int data_hex(struct sr_output *o, const char *data_in, SR_PRIV int data_hex(struct sr_output *o, const uint8_t *data_in,
uint64_t length_in, char **data_out, uint64_t *length_out); uint64_t length_in, uint8_t **data_out,
uint64_t *length_out);
SR_PRIV int init_ascii(struct sr_output *o); SR_PRIV int init_ascii(struct sr_output *o);
SR_PRIV int data_ascii(struct sr_output *o, const char *data_in, SR_PRIV int data_ascii(struct sr_output *o, const uint8_t *data_in,
uint64_t length_in, char **data_out, uint64_t length_in, uint8_t **data_out,
uint64_t *length_out); uint64_t *length_out);
#endif #endif

View File

@ -135,16 +135,16 @@ static int init(struct sr_output *o)
return SR_OK; return SR_OK;
} }
static int event(struct sr_output *o, int event_type, char **data_out, static int event(struct sr_output *o, int event_type, uint8_t **data_out,
uint64_t *length_out) uint64_t *length_out)
{ {
char *outbuf; uint8_t *outbuf;
switch (event_type) { switch (event_type) {
case SR_DF_END: case SR_DF_END:
outbuf = g_strdup("$dumpoff\n$end\n"); outbuf = (uint8_t *)g_strdup("$dumpoff\n$end\n");
*data_out = outbuf; *data_out = outbuf;
*length_out = strlen(outbuf); *length_out = strlen((const char *)outbuf);
g_free(o->internal); g_free(o->internal);
o->internal = NULL; o->internal = NULL;
break; break;
@ -157,8 +157,8 @@ static int event(struct sr_output *o, int event_type, char **data_out,
return SR_OK; return SR_OK;
} }
static int data(struct sr_output *o, const char *data_in, uint64_t length_in, static int data(struct sr_output *o, const uint8_t *data_in,
char **data_out, uint64_t *length_out) uint64_t length_in, uint8_t **data_out, uint64_t *length_out)
{ {
struct context *ctx; struct context *ctx;
unsigned int i; unsigned int i;
@ -207,7 +207,7 @@ static int data(struct sr_output *o, const char *data_in, uint64_t length_in,
ctx->prevsample = sample; ctx->prevsample = sample;
} }
*data_out = out->str; *data_out = (uint8_t *)out->str;
*length_out = out->len; *length_out = out->len;
g_string_free(out, FALSE); g_string_free(out, FALSE);

View File

@ -65,8 +65,8 @@ SR_API int sr_dev_info_get(const struct sr_dev *dev, int id, const void **data);
/*--- filter.c --------------------------------------------------------------*/ /*--- filter.c --------------------------------------------------------------*/
SR_API int sr_filter_probes(int in_unitsize, int out_unitsize, SR_API int sr_filter_probes(int in_unitsize, int out_unitsize,
const int *probelist, const unsigned char *data_in, const int *probelist, const uint8_t *data_in,
uint64_t length_in, char **data_out, uint64_t length_in, uint8_t **data_out,
uint64_t *length_out); uint64_t *length_out);
/*--- hwdriver.c ------------------------------------------------------------*/ /*--- hwdriver.c ------------------------------------------------------------*/

View File

@ -186,9 +186,10 @@ struct sr_output_format {
char *description; char *description;
int df_type; int df_type;
int (*init) (struct sr_output *o); int (*init) (struct sr_output *o);
int (*data) (struct sr_output *o, const char *data_in, int (*data) (struct sr_output *o, const uint8_t *data_in,
uint64_t length_in, char **data_out, uint64_t *length_out); uint64_t length_in, uint8_t **data_out,
int (*event) (struct sr_output *o, int event_type, char **data_out, uint64_t *length_out);
int (*event) (struct sr_output *o, int event_type, uint8_t **data_out,
uint64_t *length_out); uint64_t *length_out);
}; };