- Callback function pointer typedefs end with _t.
- Variables holding callback functions are named 'cb' everywhere.
}
SR_PRIV void sr_source_add(int fd, int events, int timeout,
- sr_receive_data_callback rcv_cb, void *user_data)
+ sr_receive_data_callback_t cb, void *user_data)
{
- sr_session_source_add(fd, events, timeout, rcv_cb, user_data);
+ sr_session_source_add(fd, events, timeout, cb, user_data);
}
int fd;
int events;
int timeout;
- sr_receive_data_callback cb;
+ sr_receive_data_callback_t cb;
void *user_data;
};
/**
* Add a datafeed callback to the current session.
*
- * @param callback Function to call when a chunk of data is received.
+ * @param cb Function to call when a chunk of data is received.
*
* @return SR_OK upon success, SR_ERR_BUG if no session exists.
*/
-SR_API int sr_session_datafeed_callback_add(sr_datafeed_callback callback)
+SR_API int sr_session_datafeed_callback_add(sr_datafeed_callback_t cb)
{
if (!session) {
sr_err("session: %s: session was NULL", __func__);
return SR_ERR_BUG;
}
- /* TODO: Is 'callback' allowed to be NULL? */
+ /* TODO: Is 'cb' allowed to be NULL? */
session->datafeed_callbacks =
- g_slist_append(session->datafeed_callbacks, callback);
+ g_slist_append(session->datafeed_callbacks, cb);
return SR_OK;
}
struct sr_datafeed_packet *packet)
{
GSList *l;
- sr_datafeed_callback cb;
+ sr_datafeed_callback_t cb;
if (!dev) {
sr_err("session: %s: dev was NULL", __func__);
* @param fd TODO.
* @param events TODO.
* @param timeout TODO.
- * @param callback TODO.
+ * @param cb TODO.
* @param user_data TODO.
*
* @return SR_OK upon success, SR_ERR_ARG upon invalid arguments, or
* SR_ERR_MALLOC upon memory allocation errors.
*/
SR_API int sr_session_source_add(int fd, int events, int timeout,
- sr_receive_data_callback callback, void *user_data)
+ sr_receive_data_callback_t cb, void *user_data)
{
struct source *new_sources, *s;
- if (!callback) {
- sr_err("session: %s: callback was NULL", __func__);
+ if (!cb) {
+ sr_err("session: %s: cb was NULL", __func__);
return SR_ERR_ARG;
}
s->fd = fd;
s->events = events;
s->timeout = timeout;
- s->cb = callback;
+ s->cb = cb;
s->user_data = user_data;
sources = new_sources;
SR_PRIV void sr_source_remove(int fd);
SR_PRIV void sr_source_add(int fd, int events, int timeout,
- sr_receive_data_callback rcv_cb, void *user_data);
+ sr_receive_data_callback_t cb, void *user_data);
/*--- hardware/common/serial.c ----------------------------------------------*/
/*--- session.c -------------------------------------------------------------*/
-typedef void (*sr_datafeed_callback)(struct sr_dev *dev,
- struct sr_datafeed_packet *packet);
+typedef void (*sr_datafeed_callback_t)(struct sr_dev *dev,
+ struct sr_datafeed_packet *packet);
/* Session setup */
SR_API int sr_session_load(const char *filename);
/* Datafeed setup */
SR_API int sr_session_datafeed_callback_clear(void);
-SR_API int sr_session_datafeed_callback_add(sr_datafeed_callback callback);
+SR_API int sr_session_datafeed_callback_add(sr_datafeed_callback_t cb);
/* Session control */
SR_API int sr_session_start(void);
SR_API int sr_session_stop(void);
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_receive_data_callback_t cb, void *user_data);
SR_API int sr_session_source_remove(int fd);
/*--- input/input.c ---------------------------------------------------------*/
/* 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);
+typedef int (*sr_receive_data_callback_t)(int fd, int revents, void *user_data);
/* Data types used by hardware drivers for dev_config_set() */
enum {
struct sr_session {
/* List of struct sr_dev* */
GSList *devs;
- /* list of sr_receive_data_callback */
+ /* list of sr_receive_data_callback_t */
GSList *datafeed_callbacks;
GTimeVal starttime;
gboolean running;