sr: Mark API functions with SR_API/SR_PRIV.
Use SR_API to mark public API symbols, and SR_PRIV for private symbols. Variables and functions marked 'static' are private already and don't need SR_PRIV. However, functions which are not static (because they need to be used in other libsigrok-internal files) but are also not meant to be part of the public libsigrok API, must use SR_PRIV. This uses the 'visibility' feature of gcc (requires gcc >= 4.0). Details: http://gcc.gnu.org/wiki/Visibility
This commit is contained in:
parent
0146970797
commit
1a081ca67d
2
README
2
README
|
@ -25,7 +25,7 @@ Requirements
|
|||
------------
|
||||
|
||||
- git
|
||||
- gcc
|
||||
- gcc (>= 4.0)
|
||||
- make
|
||||
- autoconf >= 2.63
|
||||
- automake >= 1.11
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
*
|
||||
* @return SR_OK upon success, a (negative) error code otherwise.
|
||||
*/
|
||||
int sr_init(void)
|
||||
SR_API int sr_init(void)
|
||||
{
|
||||
return load_hwplugins();
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ int sr_init(void)
|
|||
*
|
||||
* @return SR_OK upon success, a (negative) error code otherwise.
|
||||
*/
|
||||
int sr_exit(void)
|
||||
SR_API int sr_exit(void)
|
||||
{
|
||||
sr_cleanup_hwplugins();
|
||||
|
||||
|
|
|
@ -40,7 +40,9 @@ AH_TOP([#ifndef LIBSIGROK_CONFIG_H
|
|||
#define LIBSIGROK_CONFIG_H /* To stop multiple inclusions. */])
|
||||
AH_BOTTOM([#endif /* LIBSIGROK_CONFIG_H */])
|
||||
|
||||
CFLAGS="-g -Wall -Wextra"
|
||||
# Enable more compiler warnings via -Wall and -Wextra. Add -fvisibility=hidden
|
||||
# and enforce use of SR_API to explicitly mark all public API functions.
|
||||
CFLAGS="-g -Wall -Wextra -fvisibility=hidden"
|
||||
|
||||
# Checks for programs.
|
||||
AC_PROG_CXX
|
||||
|
|
|
@ -48,7 +48,7 @@ static gpointer new_chunk(struct sr_datastore **ds);
|
|||
* or SR_ERR_ARG upon invalid arguments. If something other than SR_OK
|
||||
* is returned, the value of 'ds' is undefined.
|
||||
*/
|
||||
int sr_datastore_new(int unitsize, struct sr_datastore **ds)
|
||||
SR_API int sr_datastore_new(int unitsize, struct sr_datastore **ds)
|
||||
{
|
||||
if (!ds) {
|
||||
sr_err("ds: %s: ds was NULL", __func__);
|
||||
|
@ -83,7 +83,7 @@ int sr_datastore_new(int unitsize, struct sr_datastore **ds)
|
|||
*
|
||||
* @return SR_OK upon success, SR_ERR_ARG upon invalid arguments.
|
||||
*/
|
||||
int sr_datastore_destroy(struct sr_datastore *ds)
|
||||
SR_API int sr_datastore_destroy(struct sr_datastore *ds)
|
||||
{
|
||||
GSList *chunk;
|
||||
|
||||
|
@ -129,8 +129,8 @@ int sr_datastore_destroy(struct sr_datastore *ds)
|
|||
* or SR_ERR_ARG upon invalid arguments. If something other than SR_OK
|
||||
* is returned, the value/state of 'ds' is undefined.
|
||||
*/
|
||||
int sr_datastore_put(struct sr_datastore *ds, void *data, unsigned int length,
|
||||
int in_unitsize, int *probelist)
|
||||
SR_API int sr_datastore_put(struct sr_datastore *ds, void *data,
|
||||
unsigned int length, int in_unitsize, int *probelist)
|
||||
{
|
||||
unsigned int stored;
|
||||
int capacity, size, num_chunks, chunk_bytes_free, chunk_offset;
|
||||
|
|
30
device.c
30
device.c
|
@ -57,7 +57,7 @@ static GSList *devices = NULL;
|
|||
*
|
||||
* @return SR_OK upon success, SR_ERR upon errors.
|
||||
*/
|
||||
int sr_device_scan(void)
|
||||
SR_API int sr_device_scan(void)
|
||||
{
|
||||
GSList *plugins, *l;
|
||||
struct sr_device_plugin *plugin;
|
||||
|
@ -91,7 +91,7 @@ int sr_device_scan(void)
|
|||
*
|
||||
* @return The list (GSList) of detected devices, or NULL if none were found.
|
||||
*/
|
||||
GSList *sr_device_list(void)
|
||||
SR_API GSList *sr_device_list(void)
|
||||
{
|
||||
if (!devices)
|
||||
sr_device_scan();
|
||||
|
@ -119,8 +119,8 @@ GSList *sr_device_list(void)
|
|||
*
|
||||
* @return Pointer to the newly allocated device, or NULL upon errors.
|
||||
*/
|
||||
struct sr_device *sr_device_new(const struct sr_device_plugin *plugin,
|
||||
int plugin_index)
|
||||
SR_API struct sr_device *sr_device_new(const struct sr_device_plugin *plugin,
|
||||
int plugin_index)
|
||||
{
|
||||
struct sr_device *device;
|
||||
|
||||
|
@ -156,7 +156,7 @@ struct sr_device *sr_device_new(const struct sr_device_plugin *plugin,
|
|||
* @return SR_OK upon success, SR_ERR_ARG upon invalid arguments.
|
||||
* If something other than SR_OK is returned, 'device' is unchanged.
|
||||
*/
|
||||
int sr_device_clear(struct sr_device *device)
|
||||
SR_API int sr_device_clear(struct sr_device *device)
|
||||
{
|
||||
unsigned int pnum;
|
||||
|
||||
|
@ -188,7 +188,7 @@ int sr_device_clear(struct sr_device *device)
|
|||
* upon other errors.
|
||||
* If something other than SR_OK is returned, 'device' is unchanged.
|
||||
*/
|
||||
int sr_device_probe_clear(struct sr_device *device, int probenum)
|
||||
SR_API int sr_device_probe_clear(struct sr_device *device, int probenum)
|
||||
{
|
||||
struct sr_probe *p;
|
||||
|
||||
|
@ -237,7 +237,7 @@ int sr_device_probe_clear(struct sr_device *device, int probenum)
|
|||
* or SR_ERR_ARG upon invalid arguments.
|
||||
* If something other than SR_OK is returned, 'device' is unchanged.
|
||||
*/
|
||||
int sr_device_probe_add(struct sr_device *device, const char *name)
|
||||
SR_API int sr_device_probe_add(struct sr_device *device, const char *name)
|
||||
{
|
||||
struct sr_probe *p;
|
||||
int probenum;
|
||||
|
@ -285,8 +285,8 @@ int sr_device_probe_add(struct sr_device *device, const char *name)
|
|||
* @return A pointer to the requested probe's 'struct sr_probe', or NULL
|
||||
* if the probe could not be found.
|
||||
*/
|
||||
struct sr_probe *sr_device_probe_find(const struct sr_device *device,
|
||||
int probenum)
|
||||
SR_API struct sr_probe *sr_device_probe_find(const struct sr_device *device,
|
||||
int probenum)
|
||||
{
|
||||
GSList *l;
|
||||
struct sr_probe *p, *found_probe;
|
||||
|
@ -328,8 +328,8 @@ struct sr_probe *sr_device_probe_find(const struct sr_device *device,
|
|||
* upon other errors.
|
||||
* If something other than SR_OK is returned, 'device' is unchanged.
|
||||
*/
|
||||
int sr_device_probe_name(struct sr_device *device, int probenum,
|
||||
const char *name)
|
||||
SR_API int sr_device_probe_name(struct sr_device *device, int probenum,
|
||||
const char *name)
|
||||
{
|
||||
struct sr_probe *p;
|
||||
|
||||
|
@ -364,7 +364,7 @@ int sr_device_probe_name(struct sr_device *device, int probenum,
|
|||
* @return SR_OK upon success, SR_ERR_ARG upon invalid arguments.
|
||||
* If something other than SR_OK is returned, 'device' is unchanged.
|
||||
*/
|
||||
int sr_device_trigger_clear(struct sr_device *device)
|
||||
SR_API int sr_device_trigger_clear(struct sr_device *device)
|
||||
{
|
||||
struct sr_probe *p;
|
||||
unsigned int pnum; /* TODO: uint16_t? */
|
||||
|
@ -407,8 +407,8 @@ int sr_device_trigger_clear(struct sr_device *device)
|
|||
* upon other errors.
|
||||
* If something other than SR_OK is returned, 'device' is unchanged.
|
||||
*/
|
||||
int sr_device_trigger_set(struct sr_device *device, int probenum,
|
||||
const char *trigger)
|
||||
SR_API int sr_device_trigger_set(struct sr_device *device, int probenum,
|
||||
const char *trigger)
|
||||
{
|
||||
struct sr_probe *p;
|
||||
|
||||
|
@ -449,7 +449,7 @@ int sr_device_trigger_set(struct sr_device *device, int probenum,
|
|||
* FALSE is also returned upon invalid input parameters or other
|
||||
* error conditions.
|
||||
*/
|
||||
gboolean sr_device_has_hwcap(const struct sr_device *device, int hwcap)
|
||||
SR_API gboolean sr_device_has_hwcap(const struct sr_device *device, int hwcap)
|
||||
{
|
||||
int *capabilities, i;
|
||||
|
||||
|
|
7
filter.c
7
filter.c
|
@ -73,9 +73,10 @@
|
|||
* If something other than SR_OK is returned, the values of
|
||||
* out_unitsize, data_out, and length_out are undefined.
|
||||
*/
|
||||
int sr_filter_probes(int in_unitsize, int out_unitsize, const int *probelist,
|
||||
const unsigned char *data_in, uint64_t length_in,
|
||||
char **data_out, uint64_t *length_out)
|
||||
SR_API int sr_filter_probes(int in_unitsize, int out_unitsize,
|
||||
const int *probelist, const unsigned char *data_in,
|
||||
uint64_t length_in, char **data_out,
|
||||
uint64_t *length_out)
|
||||
{
|
||||
unsigned int in_offset, out_offset;
|
||||
int num_enabled_probes, out_bit, i;
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
/* Note: This driver doesn't compile, analog support in sigrok is WIP. */
|
||||
|
||||
#include "config.h" /* Must come before sigrok.h */
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
* ASIX SIGMA Logic Analyzer Driver
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <glib.h>
|
||||
#include <glib/gstdio.h>
|
||||
#include <ftdi.h>
|
||||
|
|
|
@ -27,11 +27,10 @@
|
|||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include "config.h"
|
||||
#include "sigrok.h"
|
||||
#include "sigrok-internal.h"
|
||||
|
||||
int ezusb_reset(struct libusb_device_handle *hdl, int set_clear)
|
||||
SR_PRIV int ezusb_reset(struct libusb_device_handle *hdl, int set_clear)
|
||||
{
|
||||
int err;
|
||||
unsigned char buf[1];
|
||||
|
@ -46,7 +45,8 @@ int ezusb_reset(struct libusb_device_handle *hdl, int set_clear)
|
|||
return err;
|
||||
}
|
||||
|
||||
int ezusb_install_firmware(libusb_device_handle *hdl, const char *filename)
|
||||
SR_PRIV int ezusb_install_firmware(libusb_device_handle *hdl,
|
||||
const char *filename)
|
||||
{
|
||||
FILE *fw;
|
||||
int offset, chunksize, err, result;
|
||||
|
@ -82,8 +82,8 @@ int ezusb_install_firmware(libusb_device_handle *hdl, const char *filename)
|
|||
return result;
|
||||
}
|
||||
|
||||
int ezusb_upload_firmware(libusb_device *dev, int configuration,
|
||||
const char *filename)
|
||||
SR_PRIV int ezusb_upload_firmware(libusb_device *dev, int configuration,
|
||||
const char *filename)
|
||||
{
|
||||
struct libusb_device_handle *hdl;
|
||||
int err;
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
static HANDLE hdl;
|
||||
#endif
|
||||
|
||||
const char *serial_port_glob[] = {
|
||||
static const char *serial_port_glob[] = {
|
||||
/* Linux */
|
||||
"/dev/ttyS*",
|
||||
"/dev/ttyUSB*",
|
||||
|
@ -50,7 +50,7 @@ const char *serial_port_glob[] = {
|
|||
NULL,
|
||||
};
|
||||
|
||||
GSList *list_serial_ports(void)
|
||||
SR_PRIV GSList *list_serial_ports(void)
|
||||
{
|
||||
GSList *ports;
|
||||
|
||||
|
@ -75,7 +75,7 @@ GSList *list_serial_ports(void)
|
|||
return ports;
|
||||
}
|
||||
|
||||
int serial_open(const char *pathname, int flags)
|
||||
SR_PRIV int serial_open(const char *pathname, int flags)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
/* FIXME: Don't hardcode COM1. */
|
||||
|
@ -94,7 +94,7 @@ int serial_open(const char *pathname, int flags)
|
|||
* Close the serial port.
|
||||
* Returns 0 upon success, -1 upon failure.
|
||||
*/
|
||||
int serial_close(int fd)
|
||||
SR_PRIV int serial_close(int fd)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
/* Returns non-zero upon success, 0 upon failure. */
|
||||
|
@ -109,7 +109,7 @@ int serial_close(int fd)
|
|||
* Flush serial port buffers (if any).
|
||||
* Returns 0 upon success, -1 upon failure.
|
||||
*/
|
||||
int serial_flush(int fd)
|
||||
SR_PRIV int serial_flush(int fd)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
/* Returns non-zero upon success, 0 upon failure. */
|
||||
|
@ -124,7 +124,7 @@ int serial_flush(int fd)
|
|||
* Write a number of bytes to the specified serial port.
|
||||
* Returns the number of bytes written, or -1 upon failure.
|
||||
*/
|
||||
int serial_write(int fd, const void *buf, size_t count)
|
||||
SR_PRIV int serial_write(int fd, const void *buf, size_t count)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
DWORD tmp = 0;
|
||||
|
@ -142,7 +142,7 @@ int serial_write(int fd, const void *buf, size_t count)
|
|||
* Read a number of bytes from the specified serial port.
|
||||
* Returns the number of bytes read, or -1 upon failure.
|
||||
*/
|
||||
int serial_read(int fd, void *buf, size_t count)
|
||||
SR_PRIV int serial_read(int fd, void *buf, size_t count)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
DWORD tmp = 0;
|
||||
|
@ -156,7 +156,7 @@ int serial_read(int fd, void *buf, size_t count)
|
|||
#endif
|
||||
}
|
||||
|
||||
void *serial_backup_params(int fd)
|
||||
SR_PRIV void *serial_backup_params(int fd)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
/* TODO */
|
||||
|
@ -175,7 +175,7 @@ void *serial_backup_params(int fd)
|
|||
#endif
|
||||
}
|
||||
|
||||
void serial_restore_params(int fd, void *backup)
|
||||
SR_PRIV void serial_restore_params(int fd, void *backup)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
/* TODO */
|
||||
|
@ -190,8 +190,8 @@ void serial_restore_params(int fd, void *backup)
|
|||
* flowcontrol: 1 = rts/cts, 2 = xon/xoff
|
||||
* parity: 0 = none, 1 = even, 2 = odd
|
||||
*/
|
||||
int serial_set_params(int fd, int speed, int bits, int parity, int stopbits,
|
||||
int flowcontrol)
|
||||
SR_PRIV int serial_set_params(int fd, int speed, int bits, int parity,
|
||||
int stopbits, int flowcontrol)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
DCB dcb;
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include <fcntl.h>
|
||||
#define pipe(fds) _pipe(fds, 4096, _O_BINARY)
|
||||
#endif
|
||||
#include "config.h"
|
||||
#include "sigrok.h"
|
||||
#include "sigrok-internal.h"
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
#include <arpa/inet.h>
|
||||
#include "sigrok.h"
|
||||
#include "sigrok-internal.h"
|
||||
#include "config.h"
|
||||
#include "link-mso19.h"
|
||||
|
||||
#define USB_VENDOR "3195"
|
||||
|
|
|
@ -17,13 +17,13 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
#include <inttypes.h>
|
||||
#include <glib.h>
|
||||
#include <libusb.h>
|
||||
#include "config.h"
|
||||
#include "sigrok.h"
|
||||
#include "sigrok-internal.h"
|
||||
#include "saleae-logic.h"
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include <libusb.h>
|
||||
#include <stdio.h>
|
||||
#include "sigrok.h"
|
||||
#include "sigrok-internal.h"
|
||||
#include "gl_usb.h"
|
||||
|
||||
|
|
32
hwplugin.c
32
hwplugin.c
|
@ -17,7 +17,6 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
@ -35,7 +34,7 @@ static GSList *plugins;
|
|||
* options.
|
||||
*/
|
||||
/* TODO: This shouldn't be a global. */
|
||||
struct sr_hwcap_option sr_hwcap_options[] = {
|
||||
SR_API struct sr_hwcap_option sr_hwcap_options[] = {
|
||||
{SR_HWCAP_SAMPLERATE, SR_T_UINT64, "Sample rate", "samplerate"},
|
||||
{SR_HWCAP_CAPTURE_RATIO, SR_T_UINT64, "Pre-trigger capture ratio", "captureratio"},
|
||||
{SR_HWCAP_PATTERN_MODE, SR_T_CHAR, "Pattern generator mode", "patternmode"},
|
||||
|
@ -69,7 +68,7 @@ extern struct sr_device_plugin alsa_plugin_info;
|
|||
#endif
|
||||
|
||||
/* TODO: No linked list needed, this can be a simple array. */
|
||||
int load_hwplugins(void)
|
||||
SR_PRIV int load_hwplugins(void)
|
||||
{
|
||||
#ifdef HAVE_LA_DEMO
|
||||
plugins = g_slist_append(plugins, (gpointer *)&demo_plugin_info);
|
||||
|
@ -101,12 +100,12 @@ int load_hwplugins(void)
|
|||
return SR_OK;
|
||||
}
|
||||
|
||||
GSList *sr_list_hwplugins(void)
|
||||
SR_API GSList *sr_list_hwplugins(void)
|
||||
{
|
||||
return plugins;
|
||||
}
|
||||
|
||||
int sr_init_hwplugins(struct sr_device_plugin *plugin)
|
||||
SR_API int sr_init_hwplugins(struct sr_device_plugin *plugin)
|
||||
{
|
||||
int num_devices, num_probes, i, j;
|
||||
int num_initialized_devices = 0;
|
||||
|
@ -136,7 +135,7 @@ int sr_init_hwplugins(struct sr_device_plugin *plugin)
|
|||
return num_initialized_devices;
|
||||
}
|
||||
|
||||
void sr_cleanup_hwplugins(void)
|
||||
SR_API void sr_cleanup_hwplugins(void)
|
||||
{
|
||||
struct sr_device_plugin *plugin;
|
||||
GSList *l;
|
||||
|
@ -148,7 +147,7 @@ void sr_cleanup_hwplugins(void)
|
|||
}
|
||||
}
|
||||
|
||||
struct sr_device_instance *sr_device_instance_new(int index, int status,
|
||||
SR_API struct sr_device_instance *sr_device_instance_new(int index, int status,
|
||||
const char *vendor, const char *model, const char *version)
|
||||
{
|
||||
struct sr_device_instance *sdi;
|
||||
|
@ -167,8 +166,8 @@ struct sr_device_instance *sr_device_instance_new(int index, int status,
|
|||
return sdi;
|
||||
}
|
||||
|
||||
struct sr_device_instance *sr_get_device_instance(GSList *device_instances,
|
||||
int device_index)
|
||||
SR_API struct sr_device_instance *sr_get_device_instance(
|
||||
GSList *device_instances, int device_index)
|
||||
{
|
||||
struct sr_device_instance *sdi;
|
||||
GSList *l;
|
||||
|
@ -183,7 +182,7 @@ struct sr_device_instance *sr_get_device_instance(GSList *device_instances,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void sr_device_instance_free(struct sr_device_instance *sdi)
|
||||
SR_API void sr_device_instance_free(struct sr_device_instance *sdi)
|
||||
{
|
||||
g_free(sdi->priv);
|
||||
g_free(sdi->vendor);
|
||||
|
@ -194,7 +193,7 @@ void sr_device_instance_free(struct sr_device_instance *sdi)
|
|||
|
||||
#ifdef HAVE_LIBUSB_1_0
|
||||
|
||||
struct sr_usb_device_instance *sr_usb_device_instance_new(uint8_t bus,
|
||||
SR_PRIV struct sr_usb_device_instance *sr_usb_device_instance_new(uint8_t bus,
|
||||
uint8_t address, struct libusb_device_handle *hdl)
|
||||
{
|
||||
struct sr_usb_device_instance *udi;
|
||||
|
@ -209,7 +208,7 @@ struct sr_usb_device_instance *sr_usb_device_instance_new(uint8_t bus,
|
|||
return udi;
|
||||
}
|
||||
|
||||
void sr_usb_device_instance_free(struct sr_usb_device_instance *usb)
|
||||
SR_PRIV void sr_usb_device_instance_free(struct sr_usb_device_instance *usb)
|
||||
{
|
||||
/* Avoid compiler warnings. */
|
||||
(void)usb;
|
||||
|
@ -219,7 +218,7 @@ void sr_usb_device_instance_free(struct sr_usb_device_instance *usb)
|
|||
|
||||
#endif
|
||||
|
||||
struct sr_serial_device_instance *sr_serial_device_instance_new(
|
||||
SR_PRIV struct sr_serial_device_instance *sr_serial_device_instance_new(
|
||||
const char *port, int fd)
|
||||
{
|
||||
struct sr_serial_device_instance *serial;
|
||||
|
@ -233,12 +232,13 @@ struct sr_serial_device_instance *sr_serial_device_instance_new(
|
|||
return serial;
|
||||
}
|
||||
|
||||
void sr_serial_device_instance_free(struct sr_serial_device_instance *serial)
|
||||
SR_PRIV void sr_serial_device_instance_free(
|
||||
struct sr_serial_device_instance *serial)
|
||||
{
|
||||
free(serial->port);
|
||||
}
|
||||
|
||||
int sr_find_hwcap(int *capabilities, int hwcap)
|
||||
SR_API int sr_find_hwcap(int *capabilities, int hwcap)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -250,7 +250,7 @@ int sr_find_hwcap(int *capabilities, int hwcap)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
struct sr_hwcap_option *sr_find_hwcap_option(int hwcap)
|
||||
SR_API struct sr_hwcap_option *sr_find_hwcap_option(int hwcap)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
|
||||
#include "sigrok.h"
|
||||
#include "sigrok-internal.h"
|
||||
|
||||
extern struct sr_input_format input_chronovu_la8;
|
||||
extern struct sr_input_format input_binary;
|
||||
|
@ -29,7 +30,7 @@ static struct sr_input_format *input_module_list[] = {
|
|||
NULL,
|
||||
};
|
||||
|
||||
struct sr_input_format **sr_input_list(void)
|
||||
SR_API struct sr_input_format **sr_input_list(void)
|
||||
{
|
||||
return input_module_list;
|
||||
}
|
||||
|
|
16
log.c
16
log.c
|
@ -35,7 +35,7 @@ static int sr_loglevel = SR_LOG_WARN; /* Show errors+warnings per default. */
|
|||
* SR_LOG_INFO, SR_LOG_DBG, or SR_LOG_SPEW).
|
||||
* @return SR_OK upon success, SR_ERR_ARG upon invalid loglevel.
|
||||
*/
|
||||
int sr_set_loglevel(int loglevel)
|
||||
SR_API int sr_set_loglevel(int loglevel)
|
||||
{
|
||||
if (loglevel < SR_LOG_NONE || loglevel > SR_LOG_SPEW) {
|
||||
sr_err("log: %s: invalid loglevel %d", __func__, loglevel);
|
||||
|
@ -54,7 +54,7 @@ int sr_set_loglevel(int loglevel)
|
|||
*
|
||||
* @return The currently configured libsigrok loglevel.
|
||||
*/
|
||||
int sr_get_loglevel(void)
|
||||
SR_API int sr_get_loglevel(void)
|
||||
{
|
||||
return sr_loglevel;
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ static int sr_logv(int loglevel, const char *format, va_list args)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int sr_log(int loglevel, const char *format, ...)
|
||||
SR_PRIV int sr_log(int loglevel, const char *format, ...)
|
||||
{
|
||||
int ret;
|
||||
va_list args;
|
||||
|
@ -85,7 +85,7 @@ int sr_log(int loglevel, const char *format, ...)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int sr_spew(const char *format, ...)
|
||||
SR_PRIV int sr_spew(const char *format, ...)
|
||||
{
|
||||
int ret;
|
||||
va_list args;
|
||||
|
@ -97,7 +97,7 @@ int sr_spew(const char *format, ...)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int sr_dbg(const char *format, ...)
|
||||
SR_PRIV int sr_dbg(const char *format, ...)
|
||||
{
|
||||
int ret;
|
||||
va_list args;
|
||||
|
@ -109,7 +109,7 @@ int sr_dbg(const char *format, ...)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int sr_info(const char *format, ...)
|
||||
SR_PRIV int sr_info(const char *format, ...)
|
||||
{
|
||||
int ret;
|
||||
va_list args;
|
||||
|
@ -121,7 +121,7 @@ int sr_info(const char *format, ...)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int sr_warn(const char *format, ...)
|
||||
SR_PRIV int sr_warn(const char *format, ...)
|
||||
{
|
||||
int ret;
|
||||
va_list args;
|
||||
|
@ -133,7 +133,7 @@ int sr_warn(const char *format, ...)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int sr_err(const char *format, ...)
|
||||
SR_PRIV int sr_err(const char *format, ...)
|
||||
{
|
||||
int ret;
|
||||
va_list args;
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include <string.h>
|
||||
#include <glib.h>
|
||||
#include "sigrok.h"
|
||||
#include "config.h"
|
||||
|
||||
#define DEFAULT_BPL_BITS 64
|
||||
#define DEFAULT_BPL_HEX 192
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include <glib.h>
|
||||
#include "sigrok.h"
|
||||
#include "sigrok-internal.h"
|
||||
#include "config.h"
|
||||
|
||||
static int data(struct sr_output *o, const char *data_in, uint64_t length_in,
|
||||
char **data_out, uint64_t *length_out)
|
||||
|
|
|
@ -21,9 +21,9 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <glib.h>
|
||||
#include "config.h"
|
||||
#include "sigrok.h"
|
||||
#include "sigrok-internal.h"
|
||||
#include "config.h"
|
||||
|
||||
struct context {
|
||||
unsigned int num_enabled_probes;
|
||||
|
|
|
@ -21,9 +21,9 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <glib.h>
|
||||
#include "config.h"
|
||||
#include "sigrok.h"
|
||||
#include "sigrok-internal.h"
|
||||
#include "config.h"
|
||||
|
||||
struct context {
|
||||
unsigned int num_enabled_probes;
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
#include <glib.h>
|
||||
#include "sigrok.h"
|
||||
#include "sigrok-internal.h"
|
||||
#include "config.h"
|
||||
|
||||
struct context {
|
||||
GString *header;
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
|
||||
#include "sigrok.h"
|
||||
#include "sigrok-internal.h"
|
||||
|
||||
extern struct sr_output_format output_text_bits;
|
||||
extern struct sr_output_format output_text_hex;
|
||||
|
@ -46,7 +47,7 @@ static struct sr_output_format *output_module_list[] = {
|
|||
NULL,
|
||||
};
|
||||
|
||||
struct sr_output_format **sr_output_list(void)
|
||||
SR_API struct sr_output_format **sr_output_list(void)
|
||||
{
|
||||
return output_module_list;
|
||||
}
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <glib.h>
|
||||
#include "sigrok.h"
|
||||
#include "config.h"
|
||||
#include "sigrok.h"
|
||||
#include "text.h"
|
||||
|
||||
void flush_linebufs(struct context *ctx, char *outbuf)
|
||||
|
|
|
@ -22,9 +22,9 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <glib.h>
|
||||
#include "config.h"
|
||||
#include "sigrok.h"
|
||||
#include "sigrok-internal.h"
|
||||
#include "config.h"
|
||||
|
||||
struct context {
|
||||
int num_enabled_probes;
|
||||
|
|
30
session.c
30
session.c
|
@ -17,7 +17,6 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
@ -56,7 +55,7 @@ static int source_timeout = -1;
|
|||
*
|
||||
* @return A pointer to the newly allocated session, or NULL upon errors.
|
||||
*/
|
||||
struct sr_session *sr_session_new(void)
|
||||
SR_API struct sr_session *sr_session_new(void)
|
||||
{
|
||||
if (!(session = calloc(1, sizeof(struct sr_session)))) {
|
||||
sr_err("session: %s: session malloc failed", __func__);
|
||||
|
@ -73,7 +72,7 @@ struct sr_session *sr_session_new(void)
|
|||
*
|
||||
* @return SR_OK upon success, SR_ERR_BUG if no session exists.
|
||||
*/
|
||||
int sr_session_destroy(void)
|
||||
SR_API int sr_session_destroy(void)
|
||||
{
|
||||
if (!session) {
|
||||
sr_warn("session: %s: session was NULL", __func__);
|
||||
|
@ -101,7 +100,7 @@ int sr_session_destroy(void)
|
|||
*
|
||||
* @return SR_OK upon success, SR_ERR_BUG if no session exists.
|
||||
*/
|
||||
int sr_session_device_clear(void)
|
||||
SR_API int sr_session_device_clear(void)
|
||||
{
|
||||
if (!session) {
|
||||
sr_warn("session: %s: session was NULL", __func__);
|
||||
|
@ -123,7 +122,7 @@ int sr_session_device_clear(void)
|
|||
*
|
||||
* @return SR_OK upon success, SR_ERR_ARG upon invalid arguments.
|
||||
*/
|
||||
int sr_session_device_add(struct sr_device *device)
|
||||
SR_API int sr_session_device_add(struct sr_device *device)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
@ -165,7 +164,7 @@ int sr_session_device_add(struct sr_device *device)
|
|||
*
|
||||
* @return SR_OK upon success, SR_ERR_BUG if no session exists.
|
||||
*/
|
||||
int sr_session_datafeed_callback_clear(void)
|
||||
SR_API int sr_session_datafeed_callback_clear(void)
|
||||
{
|
||||
if (!session) {
|
||||
sr_err("session: %s: session was NULL", __func__);
|
||||
|
@ -184,7 +183,7 @@ int sr_session_datafeed_callback_clear(void)
|
|||
* @param callback TODO.
|
||||
* @return SR_OK upon success, SR_ERR_BUG if no session exists.
|
||||
*/
|
||||
int sr_session_datafeed_callback_add(sr_datafeed_callback callback)
|
||||
SR_API int sr_session_datafeed_callback_add(sr_datafeed_callback callback)
|
||||
{
|
||||
if (!session) {
|
||||
sr_err("session: %s: session was NULL", __func__);
|
||||
|
@ -258,7 +257,7 @@ static int sr_session_run_poll(void)
|
|||
*
|
||||
* @return SR_OK upon success, SR_ERR upon errors.
|
||||
*/
|
||||
int sr_session_start(void)
|
||||
SR_API int sr_session_start(void)
|
||||
{
|
||||
struct sr_device *device;
|
||||
GSList *l;
|
||||
|
@ -304,7 +303,7 @@ int sr_session_start(void)
|
|||
*
|
||||
* @return SR_OK upon success, SR_ERR_BUG upon errors.
|
||||
*/
|
||||
int sr_session_run(void)
|
||||
SR_API int sr_session_run(void)
|
||||
{
|
||||
if (!session) {
|
||||
sr_err("session: %s: session was NULL; a session must be "
|
||||
|
@ -342,7 +341,7 @@ int sr_session_run(void)
|
|||
*
|
||||
* @return SR_OK upon success, SR_ERR_BUG if no session exists.
|
||||
*/
|
||||
int sr_session_halt(void)
|
||||
SR_API int sr_session_halt(void)
|
||||
{
|
||||
if (!session) {
|
||||
sr_err("session: %s: session was NULL", __func__);
|
||||
|
@ -362,7 +361,7 @@ int sr_session_halt(void)
|
|||
*
|
||||
* @return SR_OK upon success, SR_ERR_BUG if no session exists.
|
||||
*/
|
||||
int sr_session_stop(void)
|
||||
SR_API int sr_session_stop(void)
|
||||
{
|
||||
struct sr_device *device;
|
||||
GSList *l;
|
||||
|
@ -439,7 +438,8 @@ static int datafeed_dump(struct sr_datafeed_packet *packet)
|
|||
* @param packet TODO.
|
||||
* @return SR_OK upon success, SR_ERR_ARG upon invalid arguments.
|
||||
*/
|
||||
int sr_session_bus(struct sr_device *device, struct sr_datafeed_packet *packet)
|
||||
SR_API int sr_session_bus(struct sr_device *device,
|
||||
struct sr_datafeed_packet *packet)
|
||||
{
|
||||
GSList *l;
|
||||
sr_datafeed_callback cb;
|
||||
|
@ -487,8 +487,8 @@ int sr_session_bus(struct sr_device *device, struct sr_datafeed_packet *packet)
|
|||
* @return SR_OK upon success, SR_ERR_ARG upon invalid arguments, or
|
||||
* SR_ERR_MALLOC upon memory allocation errors.
|
||||
*/
|
||||
int sr_session_source_add(int fd, int events, int timeout,
|
||||
sr_receive_data_callback callback, void *user_data)
|
||||
SR_API int sr_session_source_add(int fd, int events, int timeout,
|
||||
sr_receive_data_callback callback, void *user_data)
|
||||
{
|
||||
struct source *new_sources, *s;
|
||||
|
||||
|
@ -537,7 +537,7 @@ int sr_session_source_add(int fd, int events, int timeout,
|
|||
* SR_ERR_MALLOC upon memory allocation errors, SR_ERR_BUG upon
|
||||
* internal errors.
|
||||
*/
|
||||
int sr_session_source_remove(int fd)
|
||||
SR_API int sr_session_source_remove(int fd)
|
||||
{
|
||||
struct source *new_sources;
|
||||
int old, new;
|
||||
|
|
|
@ -17,13 +17,13 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <zip.h>
|
||||
#include <glib.h>
|
||||
#include <glib/gstdio.h>
|
||||
#include "config.h"
|
||||
#include "sigrok.h"
|
||||
#include "sigrok-internal.h"
|
||||
|
||||
|
@ -39,7 +39,7 @@ extern struct sr_device_plugin session_driver;
|
|||
* SR_ERR_MALLOC upon memory allocation errors, or SR_ERR upon
|
||||
* other errors.
|
||||
*/
|
||||
int sr_session_load(const char *filename)
|
||||
SR_API int sr_session_load(const char *filename)
|
||||
{
|
||||
GKeyFile *kf;
|
||||
GPtrArray *capturefiles;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include <stdarg.h>
|
||||
#include <glib.h>
|
||||
#include "config.h" /* Needed for HAVE_LIBUSB_1_0 and others. */
|
||||
#ifdef HAVE_LIBUSB_1_0
|
||||
#include <libusb.h>
|
||||
#endif
|
||||
|
@ -41,7 +42,7 @@
|
|||
|
||||
/*--- hwplugin.c ------------------------------------------------------------*/
|
||||
|
||||
int load_hwplugins(void);
|
||||
SR_PRIV int load_hwplugins(void);
|
||||
|
||||
#ifdef HAVE_LIBUSB_1_0
|
||||
struct sr_usb_device_instance {
|
||||
|
@ -58,56 +59,58 @@ struct sr_serial_device_instance {
|
|||
|
||||
#ifdef HAVE_LIBUSB_1_0
|
||||
/* USB-specific instances */
|
||||
struct sr_usb_device_instance *sr_usb_device_instance_new(uint8_t bus,
|
||||
SR_PRIV struct sr_usb_device_instance *sr_usb_device_instance_new(uint8_t bus,
|
||||
uint8_t address, struct libusb_device_handle *hdl);
|
||||
void sr_usb_device_instance_free(struct sr_usb_device_instance *usb);
|
||||
SR_PRIV void sr_usb_device_instance_free(struct sr_usb_device_instance *usb);
|
||||
#endif
|
||||
|
||||
/* Serial-specific instances */
|
||||
struct sr_serial_device_instance *sr_serial_device_instance_new(
|
||||
SR_PRIV struct sr_serial_device_instance *sr_serial_device_instance_new(
|
||||
const char *port, int fd);
|
||||
void sr_serial_device_instance_free(struct sr_serial_device_instance *serial);
|
||||
SR_PRIV void sr_serial_device_instance_free(
|
||||
struct sr_serial_device_instance *serial);
|
||||
|
||||
/*--- log.c -----------------------------------------------------------------*/
|
||||
|
||||
int sr_log(int loglevel, const char *format, ...);
|
||||
int sr_spew(const char *format, ...);
|
||||
int sr_dbg(const char *format, ...);
|
||||
int sr_info(const char *format, ...);
|
||||
int sr_warn(const char *format, ...);
|
||||
int sr_err(const char *format, ...);
|
||||
SR_PRIV int sr_log(int loglevel, const char *format, ...);
|
||||
SR_PRIV int sr_spew(const char *format, ...);
|
||||
SR_PRIV int sr_dbg(const char *format, ...);
|
||||
SR_PRIV int sr_info(const char *format, ...);
|
||||
SR_PRIV int sr_warn(const char *format, ...);
|
||||
SR_PRIV int sr_err(const char *format, ...);
|
||||
|
||||
/*--- hardware/common/serial.c ----------------------------------------------*/
|
||||
|
||||
GSList *list_serial_ports(void);
|
||||
int serial_open(const char *pathname, int flags);
|
||||
int serial_close(int fd);
|
||||
int serial_flush(int fd);
|
||||
int serial_write(int fd, const void *buf, size_t count);
|
||||
int serial_read(int fd, void *buf, size_t count);
|
||||
void *serial_backup_params(int fd);
|
||||
void serial_restore_params(int fd, void *backup);
|
||||
int serial_set_params(int fd, int speed, int bits, int parity, int stopbits,
|
||||
int flowcontrol);
|
||||
SR_PRIV GSList *list_serial_ports(void);
|
||||
SR_PRIV int serial_open(const char *pathname, int flags);
|
||||
SR_PRIV int serial_close(int fd);
|
||||
SR_PRIV int serial_flush(int fd);
|
||||
SR_PRIV int serial_write(int fd, const void *buf, size_t count);
|
||||
SR_PRIV int serial_read(int fd, void *buf, size_t count);
|
||||
SR_PRIV void *serial_backup_params(int fd);
|
||||
SR_PRIV void serial_restore_params(int fd, void *backup);
|
||||
SR_PRIV int serial_set_params(int fd, int speed, int bits, int parity,
|
||||
int stopbits, int flowcontrol);
|
||||
|
||||
/*--- hardware/common/ezusb.c -----------------------------------------------*/
|
||||
|
||||
#ifdef HAVE_LIBUSB_1_0
|
||||
int ezusb_reset(struct libusb_device_handle *hdl, int set_clear);
|
||||
int ezusb_install_firmware(libusb_device_handle *hdl, const char *filename);
|
||||
int ezusb_upload_firmware(libusb_device *dev, int configuration,
|
||||
const char *filename);
|
||||
SR_PRIV int ezusb_reset(struct libusb_device_handle *hdl, int set_clear);
|
||||
SR_PRIV int ezusb_install_firmware(libusb_device_handle *hdl,
|
||||
const char *filename);
|
||||
SR_PRIV int ezusb_upload_firmware(libusb_device *dev, int configuration,
|
||||
const char *filename);
|
||||
#endif
|
||||
|
||||
/*--- hardware/common/misc.c ------------------------------------------------*/
|
||||
|
||||
#ifdef HAVE_LIBUSB_1_0
|
||||
int opendev2(int device_index, struct sr_device_instance **sdi,
|
||||
libusb_device *dev, struct libusb_device_descriptor *des,
|
||||
int *skip, uint16_t vid, uint16_t pid, int interface);
|
||||
int opendev3(struct sr_device_instance **sdi, libusb_device *dev,
|
||||
struct libusb_device_descriptor *des,
|
||||
uint16_t vid, uint16_t pid, int interface);
|
||||
SR_PRIV int opendev2(int device_index, struct sr_device_instance **sdi,
|
||||
libusb_device *dev, struct libusb_device_descriptor *des,
|
||||
int *skip, uint16_t vid, uint16_t pid, int interface);
|
||||
SR_PRIV int opendev3(struct sr_device_instance **sdi, libusb_device *dev,
|
||||
struct libusb_device_descriptor *des,
|
||||
uint16_t vid, uint16_t pid, int interface);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
133
sigrok-proto.h
133
sigrok-proto.h
|
@ -22,65 +22,67 @@
|
|||
|
||||
/*--- backend.c -------------------------------------------------------------*/
|
||||
|
||||
int sr_init(void);
|
||||
int sr_exit(void);
|
||||
SR_API int sr_init(void);
|
||||
SR_API int sr_exit(void);
|
||||
|
||||
/*--- log.c -----------------------------------------------------------------*/
|
||||
|
||||
int sr_set_loglevel(int loglevel);
|
||||
int sr_get_loglevel(void);
|
||||
SR_API int sr_set_loglevel(int loglevel);
|
||||
SR_API int sr_get_loglevel(void);
|
||||
|
||||
/*--- datastore.c -----------------------------------------------------------*/
|
||||
|
||||
int sr_datastore_new(int unitsize, struct sr_datastore **ds);
|
||||
int sr_datastore_destroy(struct sr_datastore *ds);
|
||||
int sr_datastore_put(struct sr_datastore *ds, void *data, unsigned int length,
|
||||
int in_unitsize, int *probelist);
|
||||
SR_API int sr_datastore_new(int unitsize, struct sr_datastore **ds);
|
||||
SR_API int sr_datastore_destroy(struct sr_datastore *ds);
|
||||
SR_API int sr_datastore_put(struct sr_datastore *ds, void *data,
|
||||
unsigned int length, int in_unitsize,
|
||||
int *probelist);
|
||||
|
||||
/*--- device.c --------------------------------------------------------------*/
|
||||
|
||||
int sr_device_scan(void);
|
||||
GSList *sr_device_list(void);
|
||||
struct sr_device *sr_device_new(const struct sr_device_plugin *plugin,
|
||||
int plugin_index);
|
||||
int sr_device_clear(struct sr_device *device);
|
||||
int sr_device_probe_clear(struct sr_device *device, int probenum);
|
||||
int sr_device_probe_add(struct sr_device *device, const char *name);
|
||||
struct sr_probe *sr_device_probe_find(const struct sr_device *device,
|
||||
int probenum);
|
||||
int sr_device_probe_name(struct sr_device *device, int probenum,
|
||||
const char *name);
|
||||
int sr_device_trigger_clear(struct sr_device *device);
|
||||
int sr_device_trigger_set(struct sr_device *device, int probenum,
|
||||
const char *trigger);
|
||||
gboolean sr_device_has_hwcap(const struct sr_device *device, int hwcap);
|
||||
int sr_device_get_info(const struct sr_device *device, int id,
|
||||
const void **data);
|
||||
SR_API int sr_device_scan(void);
|
||||
SR_API GSList *sr_device_list(void);
|
||||
SR_API struct sr_device *sr_device_new(const struct sr_device_plugin *plugin,
|
||||
int plugin_index);
|
||||
SR_API int sr_device_clear(struct sr_device *device);
|
||||
SR_API int sr_device_probe_clear(struct sr_device *device, int probenum);
|
||||
SR_API int sr_device_probe_add(struct sr_device *device, const char *name);
|
||||
SR_API struct sr_probe *sr_device_probe_find(const struct sr_device *device,
|
||||
int probenum);
|
||||
SR_API int sr_device_probe_name(struct sr_device *device, int probenum,
|
||||
const char *name);
|
||||
SR_API int sr_device_trigger_clear(struct sr_device *device);
|
||||
SR_API int sr_device_trigger_set(struct sr_device *device, int probenum,
|
||||
const char *trigger);
|
||||
SR_API gboolean sr_device_has_hwcap(const struct sr_device *device, int hwcap);
|
||||
SR_API int sr_device_get_info(const struct sr_device *device, int id,
|
||||
const void **data);
|
||||
|
||||
/*--- filter.c --------------------------------------------------------------*/
|
||||
|
||||
int sr_filter_probes(int in_unitsize, int out_unitsize, const int *probelist,
|
||||
const unsigned char *data_in, uint64_t length_in,
|
||||
char **data_out, uint64_t *length_out);
|
||||
SR_API int sr_filter_probes(int in_unitsize, int out_unitsize,
|
||||
const int *probelist, const unsigned char *data_in,
|
||||
uint64_t length_in, char **data_out,
|
||||
uint64_t *length_out);
|
||||
|
||||
/*--- hwplugin.c ------------------------------------------------------------*/
|
||||
|
||||
GSList *sr_list_hwplugins(void);
|
||||
int sr_init_hwplugins(struct sr_device_plugin *plugin);
|
||||
void sr_cleanup_hwplugins(void);
|
||||
SR_API GSList *sr_list_hwplugins(void);
|
||||
SR_API int sr_init_hwplugins(struct sr_device_plugin *plugin);
|
||||
SR_API void sr_cleanup_hwplugins(void);
|
||||
|
||||
/* Generic device instances */
|
||||
struct sr_device_instance *sr_device_instance_new(int index,
|
||||
SR_API struct sr_device_instance *sr_device_instance_new(int index,
|
||||
int status, const char *vendor, const char *model, const char *version);
|
||||
struct sr_device_instance *sr_get_device_instance(GSList *device_instances,
|
||||
int device_index);
|
||||
void sr_device_instance_free(struct sr_device_instance *sdi);
|
||||
SR_API struct sr_device_instance *sr_get_device_instance(
|
||||
GSList *device_instances, int device_index);
|
||||
SR_API void sr_device_instance_free(struct sr_device_instance *sdi);
|
||||
|
||||
int sr_find_hwcap(int *capabilities, int hwcap);
|
||||
struct sr_hwcap_option *sr_find_hwcap_option(int hwcap);
|
||||
void sr_source_remove(int fd);
|
||||
void sr_source_add(int fd, int events, int timeout,
|
||||
sr_receive_data_callback rcv_cb, void *user_data);
|
||||
SR_API int sr_find_hwcap(int *capabilities, int hwcap);
|
||||
SR_API struct sr_hwcap_option *sr_find_hwcap_option(int hwcap);
|
||||
SR_API void sr_source_remove(int fd);
|
||||
SR_API void sr_source_add(int fd, int events, int timeout,
|
||||
sr_receive_data_callback rcv_cb, void *user_data);
|
||||
|
||||
/*--- session.c -------------------------------------------------------------*/
|
||||
|
||||
|
@ -88,43 +90,44 @@ typedef void (*sr_datafeed_callback) (struct sr_device *device,
|
|||
struct sr_datafeed_packet *packet);
|
||||
|
||||
/* Session setup */
|
||||
int sr_session_load(const char *filename);
|
||||
struct sr_session *sr_session_new(void);
|
||||
int sr_session_destroy(void);
|
||||
int sr_session_device_clear(void);
|
||||
int sr_session_device_add(struct sr_device *device);
|
||||
SR_API int sr_session_load(const char *filename);
|
||||
SR_API struct sr_session *sr_session_new(void);
|
||||
SR_API int sr_session_destroy(void);
|
||||
SR_API int sr_session_device_clear(void);
|
||||
SR_API int sr_session_device_add(struct sr_device *device);
|
||||
|
||||
/* Datafeed setup */
|
||||
int sr_session_datafeed_callback_clear(void);
|
||||
int sr_session_datafeed_callback_add(sr_datafeed_callback callback);
|
||||
SR_API int sr_session_datafeed_callback_clear(void);
|
||||
SR_API int sr_session_datafeed_callback_add(sr_datafeed_callback callback);
|
||||
|
||||
/* Session control */
|
||||
int sr_session_start(void);
|
||||
int sr_session_run(void);
|
||||
int sr_session_halt(void);
|
||||
int sr_session_stop(void);
|
||||
int sr_session_bus(struct sr_device *device, struct sr_datafeed_packet *packet);
|
||||
int sr_session_save(const char *filename);
|
||||
int sr_session_source_add(int fd, int events, int timeout,
|
||||
sr_receive_data_callback callback, void *user_data);
|
||||
int sr_session_source_remove(int fd);
|
||||
SR_API int sr_session_start(void);
|
||||
SR_API int sr_session_run(void);
|
||||
SR_API int sr_session_halt(void);
|
||||
SR_API int sr_session_stop(void);
|
||||
SR_API int sr_session_bus(struct sr_device *device,
|
||||
struct sr_datafeed_packet *packet);
|
||||
SR_API int sr_session_save(const char *filename);
|
||||
SR_API int sr_session_source_add(int fd, int events, int timeout,
|
||||
sr_receive_data_callback callback, void *user_data);
|
||||
SR_API int sr_session_source_remove(int fd);
|
||||
|
||||
/*--- input/input.c ---------------------------------------------------------*/
|
||||
|
||||
struct sr_input_format **sr_input_list(void);
|
||||
SR_API struct sr_input_format **sr_input_list(void);
|
||||
|
||||
/*--- output/output.c -------------------------------------------------------*/
|
||||
|
||||
struct sr_output_format **sr_output_list(void);
|
||||
SR_API struct sr_output_format **sr_output_list(void);
|
||||
|
||||
/*--- output/common.c -------------------------------------------------------*/
|
||||
|
||||
char *sr_samplerate_string(uint64_t samplerate);
|
||||
char *sr_period_string(uint64_t frequency);
|
||||
char **sr_parse_triggerstring(struct sr_device *device,
|
||||
const char *triggerstring);
|
||||
int sr_parse_sizestring(const char *sizestring, uint64_t *size);
|
||||
uint64_t sr_parse_timestring(const char *timestring);
|
||||
gboolean sr_parse_boolstring(const char *boolstring);
|
||||
SR_API char *sr_samplerate_string(uint64_t samplerate);
|
||||
SR_API char *sr_period_string(uint64_t frequency);
|
||||
SR_API char **sr_parse_triggerstring(struct sr_device *device,
|
||||
const char *triggerstring);
|
||||
SR_API int sr_parse_sizestring(const char *sizestring, uint64_t *size);
|
||||
SR_API uint64_t sr_parse_timestring(const char *timestring);
|
||||
SR_API gboolean sr_parse_boolstring(const char *boolstring);
|
||||
|
||||
#endif
|
||||
|
|
19
sigrok.h.in
19
sigrok.h.in
|
@ -73,6 +73,25 @@ extern "C" {
|
|||
#define SR_LOG_DBG 4
|
||||
#define SR_LOG_SPEW 5
|
||||
|
||||
/*
|
||||
* Use SR_API to mark public API symbols, and SR_PRIV for private symbols.
|
||||
*
|
||||
* Variables and functions marked 'static' are private already and don't
|
||||
* need SR_PRIV. However, functions which are not static (because they need
|
||||
* to be used in other libsigrok-internal files) but are also not meant to
|
||||
* be part of the public libsigrok API, must use SR_PRIV.
|
||||
*
|
||||
* This uses the 'visibility' feature of gcc (requires gcc >= 4.0).
|
||||
*
|
||||
* Details: http://gcc.gnu.org/wiki/Visibility
|
||||
*/
|
||||
|
||||
/* Marks public libsigrok API symbols. */
|
||||
#define SR_API __attribute__((visibility("default")))
|
||||
|
||||
/* Marks private, non-public libsigrok symbols (not part of the API). */
|
||||
#define SR_PRIV __attribute__((visibility("hidden")))
|
||||
|
||||
typedef int (*sr_receive_data_callback) (int fd, int revents, void *user_data);
|
||||
|
||||
/* Data types used by hardware plugins for set_configuration() */
|
||||
|
|
18
strutil.c
18
strutil.c
|
@ -33,7 +33,7 @@
|
|||
* @return A malloc()ed string representation of the samplerate value,
|
||||
* or NULL upon errors. The caller is responsible to free() the memory.
|
||||
*/
|
||||
char *sr_samplerate_string(uint64_t samplerate)
|
||||
SR_API char *sr_samplerate_string(uint64_t samplerate)
|
||||
{
|
||||
char *o;
|
||||
int r;
|
||||
|
@ -70,7 +70,7 @@ char *sr_samplerate_string(uint64_t samplerate)
|
|||
* @return A malloc()ed string representation of the frequency value,
|
||||
* or NULL upon errors. The caller is responsible to free() the memory.
|
||||
*/
|
||||
char *sr_period_string(uint64_t frequency)
|
||||
SR_API char *sr_period_string(uint64_t frequency)
|
||||
{
|
||||
char *o;
|
||||
int r;
|
||||
|
@ -104,8 +104,8 @@ char *sr_period_string(uint64_t frequency)
|
|||
* @param triggerstring TODO
|
||||
* @return TODO
|
||||
*/
|
||||
char **sr_parse_triggerstring(struct sr_device *device,
|
||||
const char *triggerstring)
|
||||
SR_API char **sr_parse_triggerstring(struct sr_device *device,
|
||||
const char *triggerstring)
|
||||
{
|
||||
GSList *l;
|
||||
struct sr_probe *probe;
|
||||
|
@ -189,7 +189,7 @@ char **sr_parse_triggerstring(struct sr_device *device,
|
|||
* @return SR_OK or error code
|
||||
*
|
||||
*/
|
||||
int sr_parse_sizestring(const char *sizestring, uint64_t *size)
|
||||
SR_API int sr_parse_sizestring(const char *sizestring, uint64_t *size)
|
||||
{
|
||||
int multiplier, done;
|
||||
char *s;
|
||||
|
@ -247,7 +247,7 @@ int sr_parse_sizestring(const char *sizestring, uint64_t *size)
|
|||
* TODO: picoseconds?
|
||||
* TODO: Allow both lower-case and upper-case.
|
||||
*/
|
||||
uint64_t sr_parse_timestring(const char *timestring)
|
||||
SR_API uint64_t sr_parse_timestring(const char *timestring)
|
||||
{
|
||||
uint64_t time_msec;
|
||||
char *s;
|
||||
|
@ -270,15 +270,15 @@ uint64_t sr_parse_timestring(const char *timestring)
|
|||
return time_msec;
|
||||
}
|
||||
|
||||
gboolean sr_parse_boolstring(const char *boolstr)
|
||||
SR_API gboolean sr_parse_boolstring(const char *boolstr)
|
||||
{
|
||||
if (!boolstr)
|
||||
return FALSE;
|
||||
|
||||
if (!g_strcasecmp(boolstr, "true") ||
|
||||
if (!g_strcasecmp(boolstr, "true") ||
|
||||
!g_strcasecmp(boolstr, "yes") ||
|
||||
!g_strcasecmp(boolstr, "on") ||
|
||||
!g_strcasecmp(boolstr, "1"))
|
||||
!g_strcasecmp(boolstr, "1"))
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
|
|
Loading…
Reference in New Issue