usbmodeswitch: Updated to v.1.2.6 from shibby's branch.
[tomato.git] / release / src / router / vsftpd / netstr.h
blobf99a732d6e3545d48a1d0bfd3300a9142a4961fc
1 #ifndef VSFTP_NETSTR_H
2 #define VSFTP_NETSTR_H
4 struct mystr;
5 struct vsf_session;
7 typedef int (*str_netfd_read_t)(struct vsf_session*
8 p_sess, char*,
9 unsigned int);
11 /* str_netfd_alloc()
12 * PURPOSE
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.
18 * PARAMETERS
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
29 * RETURNS
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,
34 struct mystr* p_str,
35 char term,
36 char* p_readbuf,
37 unsigned int maxlen,
38 str_netfd_read_t p_peekfunc,
39 str_netfd_read_t p_readfunc);
41 /* str_netfd_read()
42 * PURPOSE
43 * Fills contents of a string buffer object from a (typically network) file
44 * descriptor.
45 * PARAMETERS
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
49 * RETURNS
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);
55 /* str_netfd_write()
56 * PURPOSE
57 * Write the contents of a string buffer object out to a (typically network)
58 * file descriptor.
59 * PARAMETERS
60 * p_str - the string object to send
61 * fd - the file descriptor to write to
62 * RETURNS
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 */