File: netstr.h

package info (click to toggle)
vsftpd 2.0.3-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 984 kB
  • ctags: 1,059
  • sloc: ansic: 11,743; sh: 86; makefile: 80
file content (54 lines) | stat: -rw-r--r-- 2,036 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef VSFTP_NETSTR_H
#define VSFTP_NETSTR_H

struct mystr;

/* str_netfd_alloc()
 * PURPOSE
 * Read a string from a network socket into a string buffer object. The string
 * is delimited by a specified string terminator character.
 * If any network related errors occur trying to read the string, this call
 * will exit the program.
 * This method avoids reading one character at a time from the network.
 * PARAMETERS
 * p_str        - the destination string object
 * fd           - the file descriptor of the remote network socket
 * term         - the character which will terminate the string. This character
 *                is included in the returned string.
 * p_readbuf    - pointer to a scratch buffer into which to read from the
 *                network. This buffer must be at least "maxlen" characters!
 * maxlen       - maximum length of string to return. If this limit is passed,
 *                an empty string will be returned.
 */
void str_netfd_alloc(struct mystr* p_str, int fd, char term,
                     char* p_readbuf, unsigned int maxlen);

/* str_netfd_read()
 * PURPOSE
 * Fills contents of a string buffer object from a (typically network) file
 * descriptor.
 * PARAMETERS
 * p_str        - the string object to be filled
 * fd           - the file descriptor to read from
 * len          - the number of bytes to read
 * RETURNS
 * Number read on success, -1 on failure. The read is considered a failure
 * unless the full requested byte count is read.
 */
int str_netfd_read(struct mystr* p_str, int fd, unsigned int len);

/* str_netfd_write()
 * PURPOSE
 * Write the contents of a string buffer object out to a (typically network)
 * file descriptor.
 * PARAMETERS
 * p_str        - the string object to send
 * fd           - the file descriptor to write to
 * RETURNS
 * Number written on success, -1 on failure. The write is considered a failure
 * unless the full string buffer object is written.
 */
int str_netfd_write(const struct mystr* p_str, int fd);

#endif /* VSFTP_NETSTR_H */