1/* 2 * This program is free software; you can redistribute it and/or 3 * modify it under the terms of the GNU General Public License as 4 * published by the Free Software Foundation; either version 2 of 5 * the License, or (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * GNU General Public License for more details. 11 * 12 * You should have received a copy of the GNU General Public License 13 * along with this program; if not, write to the Free Software 14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 15 * MA 02111-1307 USA 16 */ 17#ifndef VSFTP_NETSTR_H 18#define VSFTP_NETSTR_H 19 20struct mystr; 21 22/* str_netfd_alloc() 23 * PURPOSE 24 * Read a string from a network socket into a string buffer object. The string 25 * is delimited by a specified string terminator character. 26 * If any network related errors occur trying to read the string, this call 27 * will exit the program. 28 * This method avoids reading one character at a time from the network. 29 * PARAMETERS 30 * p_str - the destination string object 31 * fd - the file descriptor of the remote network socket 32 * term - the character which will terminate the string. This character 33 * is included in the returned string. 34 * p_readbuf - pointer to a scratch buffer into which to read from the 35 * network. This buffer must be at least "maxlen" characters! 36 * maxlen - maximum length of string to return. If this limit is passed, 37 * an empty string will be returned. 38 */ 39void str_netfd_alloc(struct mystr* p_str, int fd, char term, 40 char* p_readbuf, unsigned int maxlen); 41 42/* str_netfd_read() 43 * PURPOSE 44 * Fills contents of a string buffer object from a (typically network) file 45 * descriptor. 46 * PARAMETERS 47 * p_str - the string object to be filled 48 * fd - the file descriptor to read from 49 * len - the number of bytes to read 50 * RETURNS 51 * Number read on success, -1 on failure. The read is considered a failure 52 * unless the full requested byte count is read. 53 */ 54int str_netfd_read(struct mystr* p_str, int fd, unsigned int len); 55 56/* str_netfd_write() 57 * PURPOSE 58 * Write the contents of a string buffer object out to a (typically network) 59 * file descriptor. 60 * PARAMETERS 61 * p_str - the string object to send 62 * fd - the file descriptor to write to 63 * RETURNS 64 * Number written on success, -1 on failure. The write is considered a failure 65 * unless the full string buffer object is written. 66 */ 67int str_netfd_write(const struct mystr* p_str, int fd); 68 69#endif /* VSFTP_NETSTR_H */ 70 71