From: Uwe Hermann Date: Tue, 8 Feb 2011 17:19:38 +0000 (+0100) Subject: Add sr_ prefix for device related API functions. X-Git-Tag: libsigrok-0.1.0~339 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=2bf4aca64ad435a09359662446762840ac55db1d;p=libsigrok.git Add sr_ prefix for device related API functions. --- diff --git a/backend.c b/backend.c index eb23ad22..17983cd7 100644 --- a/backend.c +++ b/backend.c @@ -28,5 +28,5 @@ int sr_init(void) /* TODO: Should return int to be able to report back error codes. */ void sr_exit(void) { - device_close_all(); + sr_device_close_all(); } diff --git a/device.c b/device.c index 9e4254ad..dd3a4000 100644 --- a/device.c +++ b/device.c @@ -25,7 +25,7 @@ extern struct sr_global *global; GSList *devices = NULL; -void device_scan(void) +void sr_device_scan(void) { GSList *plugins, *l; struct sr_device_plugin *plugin; @@ -39,12 +39,12 @@ void device_scan(void) */ for (l = plugins; l; l = l->next) { plugin = l->data; - device_plugin_init(plugin); + sr_device_plugin_init(plugin); } } -int device_plugin_init(struct sr_device_plugin *plugin) +int sr_device_plugin_init(struct sr_device_plugin *plugin) { int num_devices, num_probes, i; @@ -52,13 +52,13 @@ int device_plugin_init(struct sr_device_plugin *plugin) num_devices = plugin->init(NULL); for (i = 0; i < num_devices; i++) { num_probes = (int)plugin->get_device_info(i, SR_DI_NUM_PROBES); - device_new(plugin, i, num_probes); + sr_device_new(plugin, i, num_probes); } return num_devices; } -void device_close_all(void) +void sr_device_close_all(void) { struct sr_device *device; @@ -66,20 +66,20 @@ void device_close_all(void) device = devices->data; if (device->plugin && device->plugin->close) device->plugin->close(device->plugin_index); - device_destroy(device); + sr_device_destroy(device); } } -GSList *device_list(void) +GSList *sr_device_list(void) { if (!devices) - device_scan(); + sr_device_scan(); return devices; } -struct sr_device *device_new(struct sr_device_plugin *plugin, int plugin_index, +struct sr_device *sr_device_new(struct sr_device_plugin *plugin, int plugin_index, int num_probes) { struct sr_device *device; @@ -91,12 +91,12 @@ struct sr_device *device_new(struct sr_device_plugin *plugin, int plugin_index, devices = g_slist_append(devices, device); for (i = 0; i < num_probes; i++) - device_probe_add(device, NULL); + sr_device_probe_add(device, NULL); return device; } -void device_clear(struct sr_device *device) +void sr_device_clear(struct sr_device *device) { unsigned int pnum; @@ -106,10 +106,10 @@ void device_clear(struct sr_device *device) return; for (pnum = 1; pnum <= g_slist_length(device->probes); pnum++) - device_probe_clear(device, pnum); + sr_device_probe_clear(device, pnum); } -void device_destroy(struct sr_device *device) +void sr_device_destroy(struct sr_device *device) { unsigned int pnum; @@ -121,13 +121,13 @@ void device_destroy(struct sr_device *device) devices = g_slist_remove(devices, device); if (device->probes) { for (pnum = 1; pnum <= g_slist_length(device->probes); pnum++) - device_probe_clear(device, pnum); + sr_device_probe_clear(device, pnum); g_slist_free(device->probes); } g_free(device); } -void device_probe_clear(struct sr_device *device, int probenum) +void sr_device_probe_clear(struct sr_device *device, int probenum) { struct sr_probe *p; @@ -146,7 +146,7 @@ void device_probe_clear(struct sr_device *device, int probenum) } } -void device_probe_add(struct sr_device *device, char *name) +void sr_device_probe_add(struct sr_device *device, char *name) { struct sr_probe *p; char probename[16]; @@ -184,7 +184,7 @@ struct sr_probe *probe_find(struct sr_device *device, int probenum) } /* TODO: return SIGROK_ERR if probenum not found */ -void device_probe_name(struct sr_device *device, int probenum, char *name) +void sr_device_probe_name(struct sr_device *device, int probenum, char *name) { struct sr_probe *p; @@ -198,7 +198,7 @@ void device_probe_name(struct sr_device *device, int probenum, char *name) } /* TODO: return SIGROK_ERR if probenum not found */ -void device_trigger_clear(struct sr_device *device) +void sr_device_trigger_clear(struct sr_device *device) { struct sr_probe *p; unsigned int pnum; @@ -216,7 +216,7 @@ void device_trigger_clear(struct sr_device *device) } /* TODO: return SIGROK_ERR if probenum not found */ -void device_trigger_set(struct sr_device *device, int probenum, char *trigger) +void sr_device_trigger_set(struct sr_device *device, int probenum, char *trigger) { struct sr_probe *p; @@ -231,7 +231,7 @@ void device_trigger_set(struct sr_device *device, int probenum, char *trigger) } -gboolean device_has_hwcap(struct sr_device *device, int hwcap) +gboolean sr_device_has_hwcap(struct sr_device *device, int hwcap) { int *capabilities, i; diff --git a/input/input_binary.c b/input/input_binary.c index 3f3db0b0..be67f2d2 100644 --- a/input/input_binary.c +++ b/input/input_binary.c @@ -51,7 +51,7 @@ static int init(struct sr_input *in) num_probes = DEFAULT_NUM_PROBES; /* create a virtual device */ - in->vdevice = device_new(NULL, 0, num_probes); + in->vdevice = sr_device_new(NULL, 0, num_probes); return SR_OK; } diff --git a/output/output_analog.c b/output/output_analog.c index 7c5c622f..aef88c5f 100644 --- a/output/output_analog.c +++ b/output/output_analog.c @@ -133,7 +133,7 @@ static int init(struct sr_output *o, int default_spl, enum outputmode mode) snprintf(ctx->header, 511, "%s\n", PACKAGE_STRING); num_probes = g_slist_length(o->device->probes); - if (o->device->plugin && device_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) { + if (o->device->plugin && sr_device_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) { samplerate = *((uint64_t *) o->device->plugin->get_device_info( o->device->plugin_index, SR_DI_CUR_SAMPLERATE)); if (!(samplerate_s = sr_samplerate_string(samplerate))) { diff --git a/output/output_gnuplot.c b/output/output_gnuplot.c index 99ab6d6b..bf98bf15 100644 --- a/output/output_gnuplot.c +++ b/output/output_gnuplot.c @@ -79,7 +79,7 @@ static int init(struct sr_output *o) num_probes = g_slist_length(o->device->probes); comment[0] = '\0'; - if (o->device->plugin && device_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) { + if (o->device->plugin && sr_device_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) { samplerate = *((uint64_t *) o->device->plugin->get_device_info( o->device->plugin_index, SR_DI_CUR_SAMPLERATE)); if (!(frequency_s = sr_samplerate_string(samplerate))) { @@ -226,7 +226,7 @@ static int analog_init(struct sr_output *o) num_probes = g_slist_length(o->device->probes); comment[0] = '\0'; - if (o->device->plugin && device_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) { + if (o->device->plugin && sr_device_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) { samplerate = *((uint64_t *) o->device->plugin->get_device_info( o->device->plugin_index, SR_DI_CUR_SAMPLERATE)); if (!(frequency_s = sr_samplerate_string(samplerate))) { diff --git a/output/output_ols.c b/output/output_ols.c index e199bb46..5b7d467c 100644 --- a/output/output_ols.c +++ b/output/output_ols.c @@ -48,7 +48,7 @@ static void make_header(struct sr_output *o) ctx = o->internal; - if (o->device->plugin && device_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) + if (o->device->plugin && sr_device_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) samplerate = *((uint64_t *) o->device->plugin->get_device_info( o->device->plugin_index, SR_DI_CUR_SAMPLERATE)); else diff --git a/output/output_vcd.c b/output/output_vcd.c index 332a67d0..61d27a10 100644 --- a/output/output_vcd.c +++ b/output/output_vcd.c @@ -91,7 +91,7 @@ static int init(struct sr_output *o) g_string_append_printf(ctx->header, "$version %s %s $end\n", PACKAGE, PACKAGE_VERSION); - if (o->device->plugin && device_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) { + if (o->device->plugin && sr_device_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) { ctx->samplerate = *((uint64_t *) o->device->plugin->get_device_info( o->device->plugin_index, SR_DI_CUR_SAMPLERATE)); if (!((samplerate_s = sr_samplerate_string(ctx->samplerate)))) { diff --git a/output/text/text.c b/output/text/text.c index f51a8f31..98735eb4 100644 --- a/output/text/text.c +++ b/output/text/text.c @@ -107,7 +107,7 @@ int init(struct sr_output *o, int default_spl, enum outputmode mode) snprintf(ctx->header, 511, "%s\n", PACKAGE_STRING); num_probes = g_slist_length(o->device->probes); - if (o->device->plugin || device_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) { + if (o->device->plugin || sr_device_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) { samplerate = *((uint64_t *) o->device->plugin->get_device_info( o->device->plugin_index, SR_DI_CUR_SAMPLERATE)); if (!(samplerate_s = sr_samplerate_string(samplerate))) { diff --git a/session_file.c b/session_file.c index aa7a8b65..48a2747d 100644 --- a/session_file.c +++ b/session_file.c @@ -94,7 +94,7 @@ int sr_session_load(const char *filename) for (j = 0; keys[j]; j++) { val = g_key_file_get_string(kf, sections[i], keys[j], NULL); if (!strcmp(keys[j], "capturefile")) { - device = device_new(&session_driver, devcnt, 0); + device = sr_device_new(&session_driver, devcnt, 0); if (devcnt == 0) /* first device, init the plugin */ device->plugin->init((char *)filename); @@ -111,16 +111,16 @@ int sr_session_load(const char *filename) total_probes = strtoull(val, NULL, 10); device->plugin->set_configuration(devcnt, SR_HWCAP_CAPTURE_NUM_PROBES, &total_probes); for (p = 1; p <= total_probes; p++) - device_probe_add(device, NULL); + sr_device_probe_add(device, NULL); } else if (!strncmp(keys[j], "probe", 5)) { if (!device) continue; enabled_probes++; tmp_u64 = strtoul(keys[j]+5, NULL, 10); - device_probe_name(device, tmp_u64, val); + sr_device_probe_name(device, tmp_u64, val); } else if (!strncmp(keys[j], "trigger", 7)) { probenum = strtoul(keys[j]+7, NULL, 10); - device_trigger_set(device, probenum, val); + sr_device_trigger_set(device, probenum, val); } } g_strfreev(keys); @@ -189,7 +189,7 @@ int sr_session_save(char *filename) fprintf(meta, "capturefile = logic-%d\n", devcnt); fprintf(meta, "unitsize = %d\n", ds->ds_unitsize); fprintf(meta, "total probes = %d\n", g_slist_length(device->probes)); - if (device_has_hwcap(device, SR_HWCAP_SAMPLERATE)) { + if (sr_device_has_hwcap(device, SR_HWCAP_SAMPLERATE)) { samplerate = *((uint64_t *) device->plugin->get_device_info( device->plugin_index, SR_DI_CUR_SAMPLERATE)); s = sr_samplerate_string(samplerate); diff --git a/sigrok-proto.h b/sigrok-proto.h index 22aab6f5..d13a3ac2 100644 --- a/sigrok-proto.h +++ b/sigrok-proto.h @@ -34,23 +34,23 @@ void datastore_put(struct datastore *ds, void *data, unsigned int length, /*--- device.c --------------------------------------------------------------*/ -void device_scan(void); -int device_plugin_init(struct sr_device_plugin *plugin); -void device_close_all(void); -GSList *device_list(void); -struct sr_device *device_new(struct sr_device_plugin *plugin, int plugin_index, +void sr_device_scan(void); +int sr_device_plugin_init(struct sr_device_plugin *plugin); +void sr_device_close_all(void); +GSList *sr_device_list(void); +struct sr_device *sr_device_new(struct sr_device_plugin *plugin, int plugin_index, int num_probes); -void device_clear(struct sr_device *device); -void device_destroy(struct sr_device *dev); +void sr_device_clear(struct sr_device *device); +void sr_device_destroy(struct sr_device *dev); -void device_probe_clear(struct sr_device *device, int probenum); -void device_probe_add(struct sr_device *device, char *name); +void sr_device_probe_clear(struct sr_device *device, int probenum); +void sr_device_probe_add(struct sr_device *device, char *name); struct sr_probe *probe_find(struct sr_device *device, int probenum); -void device_probe_name(struct sr_device *device, int probenum, char *name); +void sr_device_probe_name(struct sr_device *device, int probenum, char *name); -void device_trigger_clear(struct sr_device *device); -void device_trigger_set(struct sr_device *device, int probenum, char *trigger); -gboolean device_has_hwcap(struct sr_device *device, int hwcap); +void sr_device_trigger_clear(struct sr_device *device); +void sr_device_trigger_set(struct sr_device *device, int probenum, char *trigger); +gboolean sr_device_has_hwcap(struct sr_device *device, int hwcap); /*--- filter.c --------------------------------------------------------------*/