From: Uwe Hermann Date: Sat, 29 Jan 2011 15:36:57 +0000 (+0100) Subject: Add sr_ prefix to input/output structs. X-Git-Tag: libsigrok-0.1.0~370 X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=f50f3f40d9238b0c50be67e52bc132aadfcf2050 Add sr_ prefix to input/output structs. --- diff --git a/input/input.c b/input/input.c index 356de7fe..465d9bb2 100644 --- a/input/input.c +++ b/input/input.c @@ -19,15 +19,15 @@ #include -extern struct input_format input_binary; +extern struct sr_input_format input_binary; -struct input_format *input_module_list[] = { +static struct sr_input_format *input_module_list[] = { /* This one has to be last, because it will take any input. */ &input_binary, NULL, }; -struct input_format **input_list(void) +struct sr_input_format **sr_input_list(void) { return input_module_list; } diff --git a/input/input_binary.c b/input/input_binary.c index 7581341a..79fe37c7 100644 --- a/input/input_binary.c +++ b/input/input_binary.c @@ -39,7 +39,7 @@ static int format_match(const char *filename) return TRUE; } -static int init(struct input *in) +static int init(struct sr_input *in) { int num_probes; @@ -56,7 +56,7 @@ static int init(struct input *in) return SR_OK; } -static int loadfile(struct input *in, const char *filename) +static int loadfile(struct sr_input *in, const char *filename) { struct datafeed_header header; struct datafeed_packet packet; @@ -98,7 +98,7 @@ static int loadfile(struct input *in, const char *filename) return SR_OK; } -struct input_format input_binary = { +struct sr_input_format input_binary = { "binary", "Raw binary", format_match, diff --git a/output/output.c b/output/output.c index 6cadd86b..b95cda77 100644 --- a/output/output.c +++ b/output/output.c @@ -19,17 +19,17 @@ #include -extern struct output_format output_text_bits; -extern struct output_format output_text_hex; -extern struct output_format output_text_ascii; -extern struct output_format output_binary; -extern struct output_format output_vcd; -extern struct output_format output_ols; -extern struct output_format output_gnuplot; -extern struct output_format output_analog_bits; -extern struct output_format output_analog_gnuplot; +extern struct sr_output_format output_text_bits; +extern struct sr_output_format output_text_hex; +extern struct sr_output_format output_text_ascii; +extern struct sr_output_format output_binary; +extern struct sr_output_format output_vcd; +extern struct sr_output_format output_ols; +extern struct sr_output_format output_gnuplot; +extern struct sr_output_format output_analog_bits; +extern struct sr_output_format output_analog_gnuplot; -struct output_format *output_module_list[] = { +static struct sr_output_format *output_module_list[] = { &output_text_bits, &output_text_hex, &output_text_ascii, @@ -42,7 +42,7 @@ struct output_format *output_module_list[] = { NULL, }; -struct output_format **output_list(void) +struct sr_output_format **sr_output_list(void) { return output_module_list; } diff --git a/output/output_analog.c b/output/output_analog.c index 075dcb2a..6a48a495 100644 --- a/output/output_analog.c +++ b/output/output_analog.c @@ -89,7 +89,7 @@ static void flush_linebufs(struct context *ctx, char *outbuf) memset(ctx->linebuf, 0, i * ctx->linebuf_len); } -static int init(struct output *o, int default_spl, enum outputmode mode) +static int init(struct sr_output *o, int default_spl, enum outputmode mode) { struct context *ctx; struct probe *probe; @@ -163,7 +163,7 @@ static int init(struct output *o, int default_spl, enum outputmode mode) return SR_OK; } -static int event(struct output *o, int event_type, char **data_out, +static int event(struct sr_output *o, int event_type, char **data_out, uint64_t *length_out) { struct context *ctx; @@ -197,12 +197,12 @@ static int event(struct output *o, int event_type, char **data_out, return SR_OK; } -static int init_bits(struct output *o) +static int init_bits(struct sr_output *o) { return init(o, DEFAULT_BPL_BITS, MODE_BITS); } -static int data_bits(struct output *o, char *data_in, uint64_t length_in, +static int data_bits(struct sr_output *o, char *data_in, uint64_t length_in, char **data_out, uint64_t *length_out) { struct context *ctx; @@ -283,12 +283,12 @@ static int data_bits(struct output *o, char *data_in, uint64_t length_in, return SR_OK; } #if 0 -static int init_hex(struct output *o) +static int init_hex(struct sr_output *o) { return init(o, DEFAULT_BPL_HEX, MODE_HEX); } -static int data_hex(struct output *o, char *data_in, uint64_t length_in, +static int data_hex(struct sr_output *o, char *data_in, uint64_t length_in, char **data_out, uint64_t *length_out) { struct context *ctx; @@ -348,12 +348,12 @@ static int data_hex(struct output *o, char *data_in, uint64_t length_in, return SR_OK; } -static int init_ascii(struct output *o) +static int init_ascii(struct sr_output *o) { return init(o, DEFAULT_BPL_ASCII, MODE_ASCII); } -static int data_ascii(struct output *o, char *data_in, uint64_t length_in, +static int data_ascii(struct sr_output *o, char *data_in, uint64_t length_in, char **data_out, uint64_t *length_out) { struct context *ctx; @@ -438,7 +438,7 @@ static int data_ascii(struct output *o, char *data_in, uint64_t length_in, } #endif -struct output_format output_analog_bits = { +struct sr_output_format output_analog_bits = { "analog_bits", "Bits (takes argument, default 64)", DF_ANALOG, @@ -447,7 +447,7 @@ struct output_format output_analog_bits = { event, }; #if 0 -struct output_format output_analog_hex = { +struct sr_output_format output_analog_hex = { "analog_hex", "Hexadecimal (takes argument, default 192)", DF_ANALOG, @@ -456,7 +456,7 @@ struct output_format output_analog_hex = { event, }; -struct output_format output_analog_ascii = { +struct sr_output_format output_analog_ascii = { "analog_ascii", "ASCII (takes argument, default 74)", DF_ANALOG, diff --git a/output/output_binary.c b/output/output_binary.c index 1c93da90..5f62dfe9 100644 --- a/output/output_binary.c +++ b/output/output_binary.c @@ -25,7 +25,7 @@ #include "config.h" -static int data(struct output *o, char *data_in, uint64_t length_in, +static int data(struct sr_output *o, char *data_in, uint64_t length_in, char **data_out, uint64_t *length_out) { char *outbuf; @@ -43,7 +43,7 @@ static int data(struct output *o, char *data_in, uint64_t length_in, return SR_OK; } -struct output_format output_binary = { +struct sr_output_format output_binary = { "binary", "Raw binary", DF_LOGIC, diff --git a/output/output_gnuplot.c b/output/output_gnuplot.c index 4fd81f2d..84b5e8c1 100644 --- a/output/output_gnuplot.c +++ b/output/output_gnuplot.c @@ -46,7 +46,7 @@ const char *gnuplot_header = "\ const char *gnuplot_header_comment = "\ # Comment: Acquisition with %d/%d probes at %s\n"; -static int init(struct output *o) +static int init(struct sr_output *o) { struct context *ctx; struct probe *probe; @@ -119,7 +119,7 @@ static int init(struct output *o) return 0; } -static int event(struct output *o, int event_type, char **data_out, +static int event(struct sr_output *o, int event_type, char **data_out, uint64_t *length_out) { struct context *ctx; @@ -141,7 +141,7 @@ static int event(struct output *o, int event_type, char **data_out, return SR_OK; } -static int data(struct output *o, char *data_in, uint64_t length_in, +static int data(struct sr_output *o, char *data_in, uint64_t length_in, char **data_out, uint64_t *length_out) { struct context *ctx; @@ -191,7 +191,7 @@ static int data(struct output *o, char *data_in, uint64_t length_in, return SR_OK; } -static int analog_init(struct output *o) +static int analog_init(struct sr_output *o) { struct context *ctx; struct probe *probe; @@ -266,7 +266,7 @@ static int analog_init(struct output *o) return 0; } -static int analog_data(struct output *o, char *data_in, uint64_t length_in, +static int analog_data(struct sr_output *o, char *data_in, uint64_t length_in, char **data_out, uint64_t *length_out) { struct context *ctx; @@ -326,7 +326,7 @@ static int analog_data(struct output *o, char *data_in, uint64_t length_in, return SR_OK; } -struct output_format output_gnuplot = { +struct sr_output_format output_gnuplot = { "gnuplot", "Gnuplot", DF_LOGIC, @@ -335,7 +335,7 @@ struct output_format output_gnuplot = { event, }; -struct output_format output_analog_gnuplot = { +struct sr_output_format output_analog_gnuplot = { "analog_gnuplot", "Gnuplot analog", DF_ANALOG, diff --git a/output/output_ols.c b/output/output_ols.c index acf10af6..91a4831d 100644 --- a/output/output_ols.c +++ b/output/output_ols.c @@ -66,7 +66,7 @@ struct context { const char *ols_header_comment = "\ # Comment: Acquisition with %d/%d probes at %s"; -static int init(struct output *o) +static int init(struct sr_output *o) { struct context *ctx; struct probe *probe; @@ -155,7 +155,7 @@ static int init(struct output *o) return 0; } -static int event(struct output *o, int event_type, char **data_out, +static int event(struct sr_output *o, int event_type, char **data_out, uint64_t *length_out) { struct context *ctx; @@ -177,7 +177,7 @@ static int event(struct output *o, int event_type, char **data_out, return SR_OK; } -static int data(struct output *o, char *data_in, uint64_t length_in, +static int data(struct sr_output *o, char *data_in, uint64_t length_in, char **data_out, uint64_t *length_out) { struct context *ctx; @@ -218,7 +218,7 @@ static int data(struct output *o, char *data_in, uint64_t length_in, return SR_OK; } -struct output_format output_ols = { +struct sr_output_format output_ols = { "ols", "OpenBench Logic Sniffer", DF_LOGIC, diff --git a/output/output_skeleton.c b/output/output_skeleton.c index 669a29cd..67e4d902 100644 --- a/output/output_skeleton.c +++ b/output/output_skeleton.c @@ -20,24 +20,24 @@ #include #include -static int init(struct output *o) +static int init(struct sr_output *o) { return 0; } -static int data(struct output *o, char *data_in, uint64_t length_in, +static int data(struct sr_output *o, char *data_in, uint64_t length_in, char **data_out, uint64_t *length_out) { return SR_OK; } -static int event(struct output *o, int event_type, char **data_out, +static int event(struct sr_output *o, int event_type, char **data_out, uint64_t *length_out) { return SR_OK; } -struct output_format output_foo = { +struct sr_output_format output_foo = { "foo", "The foo format", DF_LOGIC, diff --git a/output/output_vcd.c b/output/output_vcd.c index 06bb7f45..6833eec2 100644 --- a/output/output_vcd.c +++ b/output/output_vcd.c @@ -49,7 +49,7 @@ $dumpvars\n"; const char *vcd_header_comment = "\ $comment\n Acquisition with %d/%d probes at %s\n$end\n"; -static int init(struct output *o) +static int init(struct sr_output *o) { struct context *ctx; struct probe *probe; @@ -141,7 +141,7 @@ static int init(struct output *o) return SR_OK; } -static int event(struct output *o, int event_type, char **data_out, +static int event(struct sr_output *o, int event_type, char **data_out, uint64_t *length_out) { struct context *ctx; @@ -165,7 +165,7 @@ static int event(struct output *o, int event_type, char **data_out, return SR_OK; } -static int data(struct output *o, char *data_in, uint64_t length_in, +static int data(struct sr_output *o, char *data_in, uint64_t length_in, char **data_out, uint64_t *length_out) { struct context *ctx; @@ -222,7 +222,7 @@ static int data(struct output *o, char *data_in, uint64_t length_in, return SR_OK; } -struct output_format output_vcd = { +struct sr_output_format output_vcd = { "vcd", "Value Change Dump (VCD)", DF_LOGIC, diff --git a/output/text/ascii.c b/output/text/ascii.c index 27f5d742..e4e3e0cd 100644 --- a/output/text/ascii.c +++ b/output/text/ascii.c @@ -25,12 +25,12 @@ #include "text.h" -int init_ascii(struct output *o) +int init_ascii(struct sr_output *o) { return init(o, DEFAULT_BPL_ASCII, MODE_ASCII); } -int data_ascii(struct output *o, char *data_in, uint64_t length_in, +int data_ascii(struct sr_output *o, char *data_in, uint64_t length_in, char **data_out, uint64_t *length_out) { struct context *ctx; @@ -115,7 +115,7 @@ int data_ascii(struct output *o, char *data_in, uint64_t length_in, } -struct output_format output_text_ascii = { +struct sr_output_format output_text_ascii = { "ascii", "ASCII (takes argument, default 74)", DF_LOGIC, diff --git a/output/text/bits.c b/output/text/bits.c index 75662b80..b9b13477 100644 --- a/output/text/bits.c +++ b/output/text/bits.c @@ -25,12 +25,12 @@ #include "text.h" -int init_bits(struct output *o) +int init_bits(struct sr_output *o) { return init(o, DEFAULT_BPL_BITS, MODE_BITS); } -int data_bits(struct output *o, char *data_in, uint64_t length_in, +int data_bits(struct sr_output *o, char *data_in, uint64_t length_in, char **data_out, uint64_t *length_out) { struct context *ctx; @@ -102,7 +102,7 @@ int data_bits(struct output *o, char *data_in, uint64_t length_in, } -struct output_format output_text_bits = { +struct sr_output_format output_text_bits = { "bits", "Bits (takes argument, default 64)", DF_LOGIC, diff --git a/output/text/hex.c b/output/text/hex.c index 943ce01c..cd769aa5 100644 --- a/output/text/hex.c +++ b/output/text/hex.c @@ -25,12 +25,12 @@ #include "text.h" -int init_hex(struct output *o) +int init_hex(struct sr_output *o) { return init(o, DEFAULT_BPL_HEX, MODE_HEX); } -int data_hex(struct output *o, char *data_in, uint64_t length_in, +int data_hex(struct sr_output *o, char *data_in, uint64_t length_in, char **data_out, uint64_t *length_out) { struct context *ctx; @@ -91,7 +91,7 @@ int data_hex(struct output *o, char *data_in, uint64_t length_in, } -struct output_format output_text_hex = { +struct sr_output_format output_text_hex = { "hex", "Hexadecimal (takes argument, default 192)", DF_LOGIC, diff --git a/output/text/text.c b/output/text/text.c index 8a8e66ad..d687f06a 100644 --- a/output/text/text.c +++ b/output/text/text.c @@ -64,7 +64,7 @@ void flush_linebufs(struct context *ctx, char *outbuf) memset(ctx->linebuf, 0, i * ctx->linebuf_len); } -int init(struct output *o, int default_spl, enum outputmode mode) +int init(struct sr_output *o, int default_spl, enum outputmode mode) { struct context *ctx; struct probe *probe; @@ -137,7 +137,7 @@ int init(struct output *o, int default_spl, enum outputmode mode) return SR_OK; } -int event(struct output *o, int event_type, char **data_out, +int event(struct sr_output *o, int event_type, char **data_out, uint64_t *length_out) { struct context *ctx; diff --git a/output/text/text.h b/output/text/text.h index 89ed9892..b8b6d3b8 100644 --- a/output/text/text.h +++ b/output/text/text.h @@ -48,21 +48,21 @@ struct context { }; void flush_linebufs(struct context *ctx, char *outbuf); -int init(struct output *o, int default_spl, enum outputmode mode); -int event(struct output *o, int event_type, char **data_out, +int init(struct sr_output *o, int default_spl, enum outputmode mode); +int event(struct sr_output *o, int event_type, char **data_out, uint64_t *length_out); -int init_bits(struct output *o); -int data_bits(struct output *o, char *data_in, uint64_t length_in, +int init_bits(struct sr_output *o); +int data_bits(struct sr_output *o, char *data_in, uint64_t length_in, char **data_out, uint64_t *length_out); -int init_hex(struct output *o); -int data_hex(struct output *o, char *data_in, uint64_t length_in, +int init_hex(struct sr_output *o); +int data_hex(struct sr_output *o, char *data_in, uint64_t length_in, char **data_out, uint64_t *length_out); -int init_ascii(struct output *o); -int data_ascii(struct output *o, char *data_in, uint64_t length_in, +int init_ascii(struct sr_output *o); +int data_ascii(struct sr_output *o, char *data_in, uint64_t length_in, char **data_out, uint64_t *length_out); diff --git a/sigrok-proto.h b/sigrok-proto.h index b1d55f11..e4e32f65 100644 --- a/sigrok-proto.h +++ b/sigrok-proto.h @@ -122,11 +122,11 @@ void session_source_remove(int fd); /*--- input/input.c ---------------------------------------------------------*/ -struct input_format **input_list(void); +struct sr_input_format **sr_input_list(void); /*--- output/output.c -------------------------------------------------------*/ -struct output_format **output_list(void); +struct sr_output_format **sr_output_list(void); /*--- output/common.c -------------------------------------------------------*/ diff --git a/sigrok.h b/sigrok.h index a2d707ac..d7d8c2fa 100644 --- a/sigrok.h +++ b/sigrok.h @@ -129,35 +129,35 @@ struct analog_sample { struct analog_probe probes[]; }; -struct input { - struct input_format *format; +struct sr_input { + struct sr_input_format *format; char *param; struct device *vdevice; }; -struct input_format { +struct sr_input_format { char *extension; char *description; int (*format_match) (const char *filename); - int (*init) (struct input *in); - int (*loadfile) (struct input *in, const char *filename); + int (*init) (struct sr_input *in); + int (*loadfile) (struct sr_input *in, const char *filename); }; -struct output { - struct output_format *format; +struct sr_output { + struct sr_output_format *format; struct device *device; char *param; void *internal; }; -struct output_format { +struct sr_output_format { char *extension; char *description; int df_type; - int (*init) (struct output *o); - int (*data) (struct output *o, char *data_in, uint64_t length_in, + int (*init) (struct sr_output *o); + int (*data) (struct sr_output *o, char *data_in, uint64_t length_in, char **data_out, uint64_t *length_out); - int (*event) (struct output *o, int event_type, char **data_out, + int (*event) (struct sr_output *o, int event_type, char **data_out, uint64_t *length_out); };