Couchbase C Client
2.10.7
Asynchronous C Client for Couchbase
|
Go to the documentation of this file.
18 #ifndef LIBCOUCHBASE_COUCHBASE_H
19 #error "include libcouchbase/couchbase.h first"
77 #define LCB_IOV_LAYOUT_UIO
78 typedef struct lcb_iovec_st {
84 #define LCB_IOV_LAYOUT_WSABUF
85 typedef struct lcb_iovec_st {
91 #if defined(LIBCOUCHBASE_INTERNAL) && !defined(LCB_IOPS_V12_NO_DEPRECATE)
92 #define LCB__IOPS_CONCAT2(X, Y) X ## Y
93 #define LCB__IOPS_CONCAT(X, Y) LCB__IOPS_CONCAT2(X, Y)
94 #define LCB_IOPS_DEPRECATED(X) void (*LCB__IOPS_CONCAT(lcb__iops__dummy, __LINE__))(void)
96 #define LCB_IOPS_DEPRECATED(X) X
102 struct sockaddr *name;
107 struct sockaddr *name;
122 typedef struct lcb_io_opt_st* lcb_io_opt_t;
146 typedef void *(*lcb_io_timer_create_fn)
158 (lcb_io_opt_t iops,
void *timer);
171 (lcb_io_opt_t iops,
void *timer);
184 (lcb_io_opt_t iops,
void *timer,
204 typedef void *(*lcb_ioE_event_create_fn)
215 (lcb_io_opt_t iops,
void *event);
233 #define LCB_READ_EVENT 0x02
235 #define LCB_WRITE_EVENT 0x04
237 #define LCB_ERROR_EVENT 0x08
238 #define LCB_RW_EVENT (LCB_READ_EVENT|LCB_WRITE_EVENT)
284 lcb_SIZE buflen,
int _unused_flags);
291 lcb_SIZE buflen,
int _ignored);
306 (lcb_io_opt_t iops,
int domain,
int type,
int protocol);
313 const struct sockaddr *dst,
314 unsigned int addrlen);
320 const struct sockaddr *srcaddr,
321 unsigned int addrlen);
327 unsigned int queuelen);
350 #define LCB_IO_SOCKCHECK_PEND_IS_ERROR 1
352 #define LCB_IO_SOCKCHECK_STATUS_CLOSED 1
353 #define LCB_IO_SOCKCHECK_STATUS_OK 0
354 #define LCB_IO_SOCKCHECK_STATUS_UNKNOWN -1
376 #define LCB_IO_CNTL_GET 0
378 #define LCB_IO_CNTL_SET 1
381 #define LCB_IO_CNTL_TCP_NODELAY 1
384 #define LCB_IO_CNTL_TCP_KEEPALIVE 2
396 (lcb_io_opt_t iops,
lcb_socket_t sock,
int mode,
int option,
void *arg);
400 struct ringbuffer_st;
401 struct lcb_connection_st;
408 struct ringbuffer_st *ringbuffer;
409 struct lcb_iovec_st iov[2];
429 struct lcb_io_opt_st *parent;
446 typedef lcb_sockdata_t* (*lcb_ioC_socket_fn)
447 (lcb_io_opt_t iops,
int domain,
int type,
int protocol);
467 (lcb_io_opt_t iops, lcb_sockdata_t *sd,
468 const struct sockaddr *dst,
479 (lcb_sockdata_t *sd_server,
480 lcb_sockdata_t *sd_client,
493 lcb_sockdata_t *server_socket,
494 const struct sockaddr *listen_addr,
505 lcb_sockdata_t *sock,
510 #define lcb_io_read_cb lcb_ioC_read_callback
514 typedef lcb_io_writebuf_t* (*lcb_ioC_wballoc_fn)(lcb_io_opt_t,lcb_sockdata_t *);
519 #define lcb_io_write_cb lcb_ioC_write_callback
570 (lcb_sockdata_t *sd, lcb_SSIZE nread,
void *arg);
622 (lcb_io_opt_t iops, lcb_sockdata_t *sd,
int flags);
635 (lcb_io_opt_t iops, lcb_sockdata_t *sd,
int mode,
int option,
void *arg);
665 LCB_DEPRECATED(
typedef void (*lcb_io_error_cb)(lcb_sockdata_t *socket));
667 #define LCB_IOPS_BASE_FIELDS \
672 struct lcb_iops_evented_st {
693 struct lcb_iops_completion_st {
709 LCB_IOPS_DEPRECATED(
void (*send_error)(
struct lcb_io_opt_st*, lcb_sockdata_t*,
void(*)(lcb_sockdata_t*)));
863 lcb_loop_procs *loop_procs,
864 lcb_timer_procs *timer_procs,
865 lcb_bsd_procs *bsd_procs,
866 lcb_ev_procs *ev_procs,
871 struct lcb_iops2_st {
874 struct lcbio_TABLE *iot;
886 typedef void (*lcb__iops3fndummy)(void);
887 struct lcb_iops3_st {
889 lcb__iops3fndummy pads[17];
891 struct lcbio_TABLE *iot;
899 #define LCB_IOPROCS_VERSION 4
901 #define LCB_IOPS_BASEFLD(iops, fld) ((iops)->v.base).fld
902 #define LCB_IOPS_ERRNO(iops) LCB_IOPS_BASEFLD(iops, error)
904 struct lcb_io_opt_st {
907 void (*destructor)(
struct lcb_io_opt_st *iops);
914 struct lcb_iops_evented_st v0;
915 struct lcb_iops_completion_st v1;
916 struct lcb_iops2_st v2;
917 struct lcb_iops3_st v3;
930 (
int version, lcb_io_opt_t *io,
void *cookie);
985 LCB_IO_OPS_LIBEV = 0x04,
986 LCB_IO_OPS_SELECT = 0x05,
987 LCB_IO_OPS_WINIOCP = 0x06,
988 LCB_IO_OPS_LIBUV = 0x07
997 #ifndef __LCB_DOXYGEN__
999 typedef struct {
const char *sofile;
const char *symbol;
void *cookie; } lcb_IOCREATEOPTS_DSO;
1000 typedef struct {
lcb_io_create_fn create;
void *cookie; } lcb_IOCREATEOPS_FUNCTIONPOINTER;
1008 lcb_IOCREATEOPTS_DSO v1;
1009 lcb_IOCREATEOPS_FUNCTIONPOINTER v2;
void(* lcb_ioE_callback)(lcb_socket_t sock, short events, void *uarg)
Callback invoked for all poll-like events.
Definition: iops.h:134
lcb_io_ops_type_t type
The predefined type you want to create.
Definition: iops.h:993
void(* lcb_io_start_fn)(lcb_io_opt_t iops)
Start the event loop.
Definition: iops.h:647
void(* lcb_io_timer_cancel_fn)(lcb_io_opt_t iops, void *timer)
Cancel a pending timer callback.
Definition: iops.h:171
lcb_SSIZE(* lcb_ioE_sendv_fn)(lcb_io_opt_t iops, lcb_socket_t sock, lcb_IOV *iov, lcb_SIZE niov)
Write data from multiple buffers.
Definition: iops.h:301
void(* lcb_ioC_read2_callback)(lcb_sockdata_t *sd, lcb_SSIZE nread, void *arg)
Callback invoked when a read has been completed.
Definition: iops.h:570
Functions handling socket watcher events.
Definition: iops.h:746
void(* lcb_ioC_wbfree_fn)(lcb_io_opt_t, lcb_sockdata_t *, lcb_io_writebuf_t *)
Definition: iops.h:516
@ LCB_IO_OPS_LIBEVENT
Integrate with the libevent loop.
Definition: iops.h:987
lcb_io_writebuf_t *(* lcb_ioC_wballoc_fn)(lcb_io_opt_t, lcb_sockdata_t *)
Definition: iops.h:514
structure describing a connected socket's endpoints
Definition: iops.h:100
@ LCB_IOMODEL_EVENT
Event/Poll style.
Definition: iops.h:774
@ LCB_IO_OPS_DEFAULT
Definition: iops.h:984
int lcb_socket_t
Type representing the native socket type of the operating system.
Definition: iops.h:70
void(* lcb_io_stop_fn)(lcb_io_opt_t iops)
Pause the event loop.
Definition: iops.h:663
int(* lcb_ioC_read_fn)(lcb_io_opt_t, lcb_sockdata_t *, lcb_ioC_read_callback)
Definition: iops.h:512
int(* lcb_ioE_event_watch_fn)(lcb_io_opt_t iops, lcb_socket_t socket, void *event, short evflags, void *uarg, lcb_ioE_callback callback)
Associate an event with a socket, requesting notification when one of the events specified in 'flags'...
Definition: iops.h:266
lcb_SSIZE(* lcb_ioE_recvv_fn)(lcb_io_opt_t iops, lcb_socket_t sock, lcb_IOV *iov, lcb_SIZE niov)
Read data into a series of buffers.
Definition: iops.h:296
@ LCB_IOMODEL_COMPLETION
IOCP/Completion style.
Definition: iops.h:775
structure indicating a buffer and its size
void * cookie
Plugin-specific argument.
Definition: iops.h:994
lcb_error_t lcb_destroy_io_ops(lcb_io_opt_t op)
Destroy the plugin handle created by lcb_create_io_ops()
int(* lcb_ioE_chkclosed_fn)(lcb_io_opt_t iops, lcb_socket_t sock, int flags)
Check if a socket has been closed or not.
Definition: iops.h:372
struct lcbio_SOCKET * lcbconn
Internal socket equivalent.
Definition: iops.h:421
struct lcb_buf_info read_buffer
Definition: iops.h:424
@ LCB_IO_OPS_INVALID
Definition: iops.h:983
int(* lcb_ioC_write2_fn)(lcb_io_opt_t iops, lcb_sockdata_t *sd, lcb_IOV *iov, lcb_SIZE niov, void *uarg, lcb_ioC_write2_callback callback)
Schedule a flush of a series of buffers to the network.
Definition: iops.h:555
lcb_error_t lcb_create_io_ops(lcb_io_opt_t *op, const struct lcb_create_io_ops_st *options)
Create a new instance of one of the library-supplied io ops types.
unsigned int(* lcb_ioC_close_fn)(lcb_io_opt_t iops, lcb_sockdata_t *sd)
Asynchronously shutdown the socket.
Definition: iops.h:609
void(* lcb_io_connect_cb)(lcb_sockdata_t *socket, int status)
Callback to be invoked upon a connection result.
Definition: iops.h:455
lcb_iomodel_t
Enumeration defining the I/O model.
Definition: iops.h:773
lcb_error_t
Error codes returned by the library.
Definition: error.h:476
void(* lcb_ioC_write2_callback)(lcb_sockdata_t *sd, int status, void *arg)
Callback received when a buffer has been flushed.
Definition: iops.h:533
void(* lcb_ioE_event_destroy_fn)(lcb_io_opt_t iops, void *event)
Destroy an event handle.
Definition: iops.h:215
int(* lcb_ioE_connect_fn)(lcb_io_opt_t iops, lcb_socket_t sock, const struct sockaddr *dst, unsigned int addrlen)
Connect a created socket.
Definition: iops.h:311
int closed
Definition: iops.h:422
int is_reading
Internally used by lcbio.
Definition: iops.h:423
lcb_SSIZE(* lcb_ioE_send_fn)(lcb_io_opt_t iops, lcb_socket_t sock, const void *srcbuf, lcb_SIZE buflen, int _ignored)
Send data from a single buffer.
Definition: iops.h:290
int(* lcb_ioE_bind_fn)(lcb_io_opt_t iops, lcb_socket_t sock, const struct sockaddr *srcaddr, unsigned int addrlen)
Definition: iops.h:318
IO Creation for builtin plugins.
Definition: iops.h:992
int(* lcb_ioE_cntl_fn)(lcb_io_opt_t iops, lcb_socket_t sock, int mode, int option, void *arg)
Execute a specificied operation on a socket.
Definition: iops.h:396
lcb_socket_t(* lcb_ioE_socket_fn)(lcb_io_opt_t iops, int domain, int type, int protocol)
Create a new socket.
Definition: iops.h:306
Common functions for starting and stopping timers.
Definition: iops.h:715
void *(* lcb_io_timer_create_fn)(lcb_io_opt_t iops)
Create a new timer object.
Definition: iops.h:147
void(* lcb_ioC_read_callback)(lcb_sockdata_t *sd, lcb_SSIZE nread)
Definition: iops.h:509
int(* lcb_io_timer_schedule_fn)(lcb_io_opt_t iops, void *timer, lcb_U32 usecs, void *uarg, lcb_ioE_callback callback)
Schedule a callback to be invoked within a given interval.
Definition: iops.h:184
int(* lcb_ioE_listen_fn)(lcb_io_opt_t iops, lcb_socket_t bound_sock, unsigned int queuelen)
Definition: iops.h:325
int(* lcb_ioC_nameinfo_fn)(lcb_io_opt_t iops, lcb_sockdata_t *sock, struct lcb_nameinfo_st *ni)
Request address information on a connected socket.
Definition: iops.h:504
void(* lcb_io_tick_fn)(lcb_io_opt_t iops)
Run a single iteration of the event loop without blocking.
Definition: iops.h:654
lcb_socket_t socket
System socket, for informational purposes.
Definition: iops.h:419
lcb_sockdata_t *(* lcb_ioC_socket_fn)(lcb_io_opt_t iops, int domain, int type, int protocol)
Create a completion socket handle.
Definition: iops.h:447
Common functions for starting and stopping the event loop.
Definition: iops.h:723
void(* lcb_io_timer_destroy_fn)(lcb_io_opt_t iops, void *timer)
Destroy a timer handler.
Definition: iops.h:158
lcb_error_t(* lcb_io_create_fn)(int version, lcb_io_opt_t *io, void *cookie)
Signature for a loadable plugin's IOPS initializer.
Definition: iops.h:930
lcb_SSIZE(* lcb_ioE_recv_fn)(lcb_io_opt_t iops, lcb_socket_t sock, void *target_buf, lcb_SIZE buflen, int _unused_flags)
Receive data into a single buffer.
Definition: iops.h:283
Functions wrapping the Berkeley Socket API.
Definition: iops.h:730
Socket handle for completion-based I/O.
Definition: iops.h:418
int(* lcb_ioC_write_fn)(lcb_io_opt_t, lcb_sockdata_t *, lcb_io_writebuf_t *, lcb_ioC_write_callback)
Definition: iops.h:523
Functions for completion-based I/O.
Definition: iops.h:754
void(* lcb_ioE_event_cancel_fn)(lcb_io_opt_t iops, lcb_socket_t sock, void *event)
Cancel pending callbacks and unwatch a handle.
Definition: iops.h:229
void(* lcb_io_procs_fn)(int version, lcb_loop_procs *loop_procs, lcb_timer_procs *timer_procs, lcb_bsd_procs *bsd_procs, lcb_ev_procs *ev_procs, lcb_completion_procs *completion_procs, lcb_iomodel_t *iomodel)
Definition: iops.h:862
void() lcb_ioC_serve_callback(lcb_sockdata_t *sd_server, lcb_sockdata_t *sd_client, int status)
Callback invoked when a new client connection has been established.
Definition: iops.h:479
int(* lcb_ioC_read2_fn)(lcb_io_opt_t iops, lcb_sockdata_t *sd, lcb_IOV *iov, lcb_SIZE niov, void *uarg, lcb_ioC_read2_callback callback)
Schedule a read from the network.
Definition: iops.h:587
void *(* lcb_ioE_event_create_fn)(lcb_io_opt_t iops)
Create a new event handle.
Definition: iops.h:205
@ LCB_IO_OPS_WINSOCK
Definition: iops.h:988
int(* lcb_ioC_connect_fn)(lcb_io_opt_t iops, lcb_sockdata_t *sd, const struct sockaddr *dst, unsigned int naddr, lcb_io_connect_cb callback)
Request a connection for a socket.
Definition: iops.h:467
int(* lcb_ioC_chkclosed_fn)(lcb_io_opt_t iops, lcb_sockdata_t *sd, int flags)
This is the completion variant of lcb_ioE_chkclosed_fn.
Definition: iops.h:622
void lcb_iops_wire_bsd_impl2(lcb_bsd_procs *procs, int version)
lcb_io_ops_type_t
Built-in I/O plugins.
Definition: iops.h:978
lcb_io_opt_t parent
Parent I/O context.
Definition: iops.h:420
void(* lcb_ioC_write_callback)(lcb_sockdata_t *, lcb_io_writebuf_t *, int)
Definition: iops.h:518
lcb_socket_t(* lcb_ioE_accept_fn)(lcb_io_opt_t iops, lcb_socket_t lsnsock)
Definition: iops.h:331
int(* lcb_ioC_cntl_fn)(lcb_io_opt_t iops, lcb_sockdata_t *sd, int mode, int option, void *arg)
Definition: iops.h:635
void(* lcb_ioE_close_fn)(lcb_io_opt_t iops, lcb_socket_t sock)
Close a socket.
Definition: iops.h:337
int(* lcb_ioC_serve_fn)(lcb_io_opt_t iops, lcb_sockdata_t *server_socket, const struct sockaddr *listen_addr, lcb_ioC_serve_callback callback)
Specify that the socket start accepting connections.
Definition: iops.h:492