URI:
       tSConn.h - plan9port - [fork] Plan 9 from user space
  HTML git clone git://src.adamsgaard.dk/plan9port
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
       tSConn.h (990B)
       ---
            1 /* delimited, authenticated, encrypted connection */
            2 enum{ Maxmsg=4096 };        /* messages > Maxmsg bytes are truncated */
            3 typedef struct SConn SConn;
            4 
            5 extern SConn* newSConn(int);        /* arg is open file descriptor */
            6 struct SConn{
            7         void *chan;
            8         int secretlen;
            9         int (*secret)(SConn*, uchar*, int);/*  */
           10         int (*read)(SConn*, uchar*, int); /* <0 if error;  errmess in buffer */
           11         int (*write)(SConn*, uchar*, int);
           12         void (*free)(SConn*);                /* also closes file descriptor */
           13 };
           14 /* secret(s,b,dir) sets secret for digest, encrypt, using the secretlen */
           15 /*                bytes in b to form keys         for the two directions; */
           16 /*          set dir=0 in client, dir=1 in server */
           17 
           18 /* error convention: write !message in-band */
           19 extern void writerr(SConn*, char*);
           20 extern int readstr(SConn*, char*);  /* call with buf of size Maxmsg+1 */
           21         /* returns -1 upon error, with error message in buf */
           22 
           23 extern void *emalloc(ulong); /* dies on failure; clears memory */
           24 extern void *erealloc(void *, ulong);
           25 extern char *estrdup(char *);