typedef char* KEY; // gives a channel id // path has to exist // -1 on error int ctok(char *path); /// Channel creation // first caller will create channel // cid can be CHAN_PRIVATE, which will always be a unique cid // Function returns -1 on error // Receiver will get private key, sender will get public key of sender // The receiver call will never block but sender might block until receiver // calls the get function CHANNEL chnget_sender(int cid); CHANNEL chnget_receiver(int cid); /// Closes a channel // All subsequent reads or writes on this channel will fail // (even those on the matching process) void chan_close(CHANNEL c); /// Send and receive on channel, note that only the sender side can send, /// and vice versa // Output on chan; will block until receiver receives data int chan_out(CHANNEL c, char *buf, int size); // Input from chan; will block until data is received // options can be 0 which will fail if data is larger than size // or CHAN_TRUNC that will truncate if message is larger // size is always updated with size of message received // -1 on error int chan_in(CHANNEL, char *buf, int *size, int options); // will block on multiple output channels, only one can succeed // -1 on error // will return channel number that unblocked the call (starting from 0) int chanalt_out(const CHANNEL ca[], int chan_nos, char *buf, int size); int chanalt_outl(char *buf, int size,int chan_nos, const CHANNEL c1,...); // will block on multiple input channels, only one can succeed // -1 on error // options and size like chan_in // will return channel number that unblocked the call (starting from 0) int chanalt_in(const CHANNEL ca[], int chan_nos, char *buf, int *size, int options); int chanalt_inl(char *buf, int* size, int options, int chan_nos, const CHANNEL c1,...); // to be called to generate a new set of private and // public key void generate(KEY *private,KEY *public); // called with a key will encode or decode your buffer void code(char *buf,int size,KEY key);