2014-08-31 16:09:25 +00:00
|
|
|
#ifndef _TRANSPORT_H_
|
|
|
|
#define _TRANSPORT_H_
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2015-01-29 00:49:53 +00:00
|
|
|
#ifndef HAVE_EPRINTF
|
|
|
|
#include <stdio.h>
|
2017-05-09 12:25:57 +00:00
|
|
|
#define eprintf(...) { fprintf(stderr,##__VA_ARGS__); }
|
2015-01-29 00:49:53 +00:00
|
|
|
#define HAVE_EPRINTF 1
|
|
|
|
#endif
|
|
|
|
|
2014-08-31 16:09:25 +00:00
|
|
|
enum {
|
|
|
|
E_OK = 0,
|
|
|
|
E_TIMEOUT = -1,
|
|
|
|
E_ERROR = -2,
|
|
|
|
E_NOIF = -3,
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct io_backend_t {
|
|
|
|
const char *name;
|
|
|
|
int (* init)(void);
|
|
|
|
int (* deinit)(void);
|
|
|
|
void *(* open)(const char *path);
|
|
|
|
int (* close)(void *);
|
|
|
|
int (* config)(void *, void *);
|
|
|
|
int (* read)(void *, uint8_t *buf, const uint64_t count, const int timeout);
|
2014-12-08 22:38:13 +00:00
|
|
|
int (* write)(void *, const uint8_t *buf, const uint64_t count, const int timeout);
|
2014-08-31 16:09:25 +00:00
|
|
|
} io_backend_t;
|
|
|
|
|
|
|
|
int iob_select (const char *name);
|
|
|
|
|
|
|
|
void *iob_open (const char *path);
|
|
|
|
int iob_close (void *);
|
|
|
|
int iob_config (void *, void *);
|
2014-12-08 22:38:13 +00:00
|
|
|
int iob_write (void *fp, const uint8_t *buf, const uint32_t buf_len);
|
2014-08-31 16:09:25 +00:00
|
|
|
int iob_read (void *fp, uint8_t *buf, const uint32_t buf_len);
|
|
|
|
|
|
|
|
#endif
|