mirror of
https://github.com/3proxy/3proxy.git
synced 2025-04-16 17:22:09 +08:00
simlify sockgetline
This commit is contained in:
parent
572a5b3c34
commit
0376e54196
@ -156,15 +156,11 @@ int sockgetcharsrv(struct clientparam * param, int timeosec, int timeousec){
|
||||
int sockgetlinebuf(struct clientparam * param, DIRECTION which, unsigned char * buf, int bufsize, int delim, int to){
|
||||
int c;
|
||||
int i=0;
|
||||
if(bufsize < 1) return 0;
|
||||
c = (which)?sockgetcharsrv(param, to, 0):sockgetcharcli(param, to, 0);
|
||||
if (c == EOF) {
|
||||
return 0;
|
||||
}
|
||||
do {
|
||||
|
||||
while(i < bufsize && (c = (which)?sockgetcharsrv(param, to, 0):sockgetcharcli(param, to, 0)) != EOF){
|
||||
buf[i++] = c;
|
||||
if(delim != EOF && c == delim) break;
|
||||
}while(i < bufsize && (c = (which)?sockgetcharsrv(param, to, 0):sockgetcharcli(param, to, 0)) != EOF);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user