Cleanup and simplify get_reason() and related functions
Rename randreason() to fread_random() to better reflect its function, and change it to a one-pass algorithm. Have it write into a caller-provided buffer instead of a static buffer. Fixes a file leak when an empty file is given to this function. Change freadln() so that it never returns an empty line - it only returns 0 at end-of-file now. This simplifies its callers. Factor out some common code from the several get_reason()-type functions, which greatly simplifies them.
This commit is contained in:
@@ -130,8 +130,7 @@ ChannelList * BX_prepare_command (int *, char *, int);
|
||||
void set_nslookupfd(fd_set *);
|
||||
long print_nslookup(fd_set *);
|
||||
void auto_nslookup();
|
||||
int freadln(FILE *, char *);
|
||||
|
||||
int freadln(FILE *, char *, size_t);
|
||||
|
||||
void BX_close_socketread(int);
|
||||
int BX_add_socketread(int, int, unsigned long, char *, void (*func_read)(int), void (*func_write)(int));
|
||||
|
||||
Reference in New Issue
Block a user