1DC_PLUG_READ(2)                    distcache                   DC_PLUG_READ(2)
2
3
4

NAME

6       DC_PLUG_read, DC_PLUG_consume, DC_PLUG_write, DC_PLUG_write_more,
7       DC_PLUG_commit, DC_PLUG_rollback - DC_PLUG read/write functions
8

SYNOPSIS

10        #include <distcache/dc_plug.h>
11
12        int DC_PLUG_read(DC_PLUG *plug, int resume, unsigned long *request_uid,
13                         DC_CMD *cmd, const unsigned char **payload_data,
14                         unsigned int *payload_len);
15        int DC_PLUG_consume(DC_PLUG *plug);
16        int DC_PLUG_write(DC_PLUG *plug, int resume, unsigned long request_uid,
17                          DC_CMD cmd, const unsigned char *payload_data,
18                          unsigned int payload_len);
19        int DC_PLUG_write_more(DC_PLUG *plug, const unsigned char *data,
20                               unsigned int data_len);
21        int DC_PLUG_commit(DC_PLUG *plug);
22        int DC_PLUG_rollback(DC_PLUG *plug);
23
24        typedef enum {
25                DC_CMD_ERROR,
26                DC_CMD_ADD,
27                DC_CMD_GET,
28                DC_CMD_REMOVE,
29                DC_CMD_HAVE
30        } DC_CMD;
31

DESCRIPTION

33       DC_PLUG_read() will attempt to open the next distcache message received
34       by plug for reading. This message will block the reading of any other
35       received messages remain until DC_PLUG_consume() is called. If a mes‐
36       sage has already been opened for reading inside plug, then
37       DC_PLUG_read() will fail unless resume is set to non-zero in which case
38       it will simply re-open the message that was already being read. If
39       DC_PLUG_read() succeeds, request_uid, cmd, payload_data and payload_len
40       are populated with the message's data. Note that payload_data points to
41       the original data stored inside plug and this pointer is only valid
42       until the next call to DC_PLUG_consume().
43
44       DC_PLUG_consume() will close the message currently opened for reading
45       in plug, and will allow a future call to DC_PLUG_read() to succeed if
46       there any subsequent (complete) messages received from the plug
47       object's connection.
48
49       DC_PLUG_write() will attempt to open a distcache message for writing in
50       plug. If successful, this message will block the writing of any other
51       messages until the message is committed with DC_PLUG_commit() or dis‐
52       carded with DC_PLUG_rollback(). If a message has already been opened
53       for writing, DC_PLUG_write() will fail unless resume is non-zero in
54       which case the message will be re-opened and will overwrite the set‐
55       tings from the previous DC_PLUG_write() call. This is equivalent to
56       DC_PLUG_rollback() followed immediately by DC_PLUG_write() with a zero
57       resume value. Note that payload_len can be zero (and thus payload_data
58       can be NULL) even if the message will eventually have payload data -
59       this can be supplemented afterwards using the DC_PLUG_write_more()
60       function. request_uid and cmd, on the other hand, must be specified at
61       once in DC_PLUG_write().
62
63       DC_PLUG_write_more() will attempt to add more payload data to the mes‐
64       sage currently opened for writing in plug. This data will be concate‐
65       nated to the end of any payload data already provided in prior calls to
66       DC_PLUG_write() or DC_PLUG_write_more().
67
68       DC_PLUG_commit() will close the message currently opened for writing,
69       and queue it for serialisation out on the plug object's connection.
70
71       DC_PLUG_rollback() will discard the message currently opened for writ‐
72       ing.
73

RETURN VALUES

75       All these DC_PLUG functions return zero on failure, otherwise non-zero.
76

SEE ALSO

78       DC_PLUG_new(2) - Basic DC_PLUG functions.
79
80       distcache(8) - Overview of the distcache architecture.
81
82       http://www.distcache.org/ - Distcache home page.
83

AUTHOR

85       This toolkit was designed and implemented by Geoff Thorpe for Crypto‐
86       graphic Appliances Incorporated. Since the project was released into
87       open source, it has a home page and a project environment where devel‐
88       opment, mailing lists, and releases are organised. For problems with
89       the software or this man page please check for new releases at the
90       project web-site below, mail the users mailing list described there, or
91       contact the author at geoff@geoffthorpe.net.
92
93       Home Page: http://www.distcache.org
94
95
96
971.4.5                             2004.03.23                   DC_PLUG_READ(2)
Impressum