7 typedef int (*str_netfd_read_t
)(struct vsf_session
*
13 * Read a string from a network socket into a string buffer object. The string
14 * is delimited by a specified string terminator character.
15 * If any network related errors occur trying to read the string, this call
16 * will exit the program.
17 * This method avoids reading one character at a time from the network.
19 * p_sess - the session object, used for passing into the I/O callbacks
20 * p_str - the destination string object
21 * term - the character which will terminate the string. This character
22 * is included in the returned string.
23 * p_readbuf - pointer to a scratch buffer into which to read from the
24 * network. This buffer must be at least "maxlen" characters!
25 * maxlen - maximum length of string to return. If this limit is passed,
26 * an empty string will be returned.
27 * p_peekfunc - a function called to peek data from the network
28 * p_readfunc - a function called to read data from the network
30 * -1 upon reaching max buffer length without seeing terminator, or the number
31 * of bytes read, _excluding_ the terminator.
33 int str_netfd_alloc(struct vsf_session
* p_sess
,
38 str_netfd_read_t p_peekfunc
,
39 str_netfd_read_t p_readfunc
);
43 * Fills contents of a string buffer object from a (typically network) file
46 * p_str - the string object to be filled
47 * fd - the file descriptor to read from
48 * len - the number of bytes to read
50 * Number read on success, -1 on failure. The read is considered a failure
51 * unless the full requested byte count is read.
53 int str_netfd_read(struct mystr
* p_str
, int fd
, unsigned int len
);
57 * Write the contents of a string buffer object out to a (typically network)
60 * p_str - the string object to send
61 * fd - the file descriptor to write to
63 * Number written on success, -1 on failure. The write is considered a failure
64 * unless the full string buffer object is written.
66 int str_netfd_write(const struct mystr
* p_str
, int fd
);
68 #endif /* VSFTP_NETSTR_H */