1LBER_SOCKBUF(3)            Library Functions Manual            LBER_SOCKBUF(3)
2
3
4

NAME

6       ber_sockbuf_alloc,    ber_sockbuf_free,   ber_sockbuf_ctrl,   ber_sock‐
7       buf_add_io, ber_sockbuf_remove_io, Sockbuf_IO - OpenLDAP LBER  I/O  in‐
8       frastructure
9

LIBRARY

11       OpenLDAP LBER (liblber, -llber)
12

SYNOPSIS

14       #include <lber.h>
15
16       Sockbuf *ber_sockbuf_alloc( void );
17
18       void ber_sockbuf_free(Sockbuf *sb);
19
20       int ber_sockbuf_ctrl(Sockbuf *sb, int opt, void *arg);
21
22       int  ber_sockbuf_add_io(Sockbuf  *sb, Sockbuf_IO *sbio, int layer, void
23       *arg);
24
25       int ber_sockbuf_remove_io(Sockbuf *sb, Sockbuf_IO *sbio, int layer);
26
27       typedef struct sockbuf_io_desc {
28       int sbiod_level;
29       Sockbuf *sbiod_sb;
30       Sockbuf_IO *sbiod_io;
31       void *sbiod_pvt;
32       struct sockbuf_io_desc *sbiod_next;
33       } Sockbuf_IO_Desc;
34
35       typedef struct sockbuf_io {
36       int (*sbi_setup)(Sockbuf_IO_Desc *sbiod, void *arg);
37       int (*sbi_remove)(Sockbuf_IO_Desc *sbiod);
38       int (*sbi_ctrl)(Sockbuf_IO_Desc *sbiod, int opt, void *arg);
39       ber_slen_t (*sbi_read)(Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len);
40       ber_slen_t (*sbi_write)(Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len);
41       int (*sbi_close)(Sockbuf_IO_Desc *sbiod);
42       } Sockbuf_IO;
43
44

DESCRIPTION

46       These routines are used to manage the low  level  I/O  operations  per‐
47       formed  by  the  Lightweight BER library. They are called implicitly by
48       the other libraries and usually do not need to be called directly  from
49       applications.   The I/O framework is modularized and new transport lay‐
50       ers can be supported by appropriately defining a  Sockbuf_IO  structure
51       and  installing  it  onto  an existing Sockbuf.  Sockbuf structures are
52       allocated and  freed  by  ber_sockbuf_alloc()  and  ber_sockbuf_free(),
53       respectively.  The  ber_sockbuf_ctrl()  function is used to get and set
54       options related to a Sockbuf or to a specific I/O layer of the Sockbuf.
55       The ber_sockbuf_add_io() and ber_sockbuf_remove_io() functions are used
56       to add and remove specific I/O layers on a Sockbuf.
57
58       Options for ber_sockbuf_ctrl() include:
59
60       LBER_SB_OPT_HAS_IO
61              Takes a Sockbuf_IO * argument and returns 1 if the given handler
62              is installed on the Sockbuf, otherwise returns 0.
63
64       LBER_SB_OPT_GET_FD
65              Retrieves  the  file  descriptor  associated to the Sockbuf; arg
66              must be a ber_socket_t *.  The return value will be 1 if a valid
67              descriptor was present, -1 otherwise.
68
69       LBER_SB_OPT_SET_FD
70              Sets  the  file  descriptor  of  the  Sockbuf  to the descriptor
71              pointed to by arg; arg must be a  ber_socket_t  *.   The  return
72              value will always be 1.
73
74       LBER_SB_OPT_SET_NONBLOCK
75              Toggles the non-blocking state of the file descriptor associated
76              to the Sockbuf.  arg should be NULL to disable and  non-NULL  to
77              enable  the  non-blocking state.  The return value will be 1 for
78              success, -1 otherwise.
79
80       LBER_SB_OPT_DRAIN
81              Flush (read and discard) all available  input  on  the  Sockbuf.
82              The return value will be 1.
83
84       LBER_SB_OPT_NEEDS_READ
85              Returns non-zero if input is waiting to be read.
86