mirror of
https://github.com/3proxy/3proxy.git
synced 2025-04-22 04:02:08 +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 sockgetlinebuf(struct clientparam * param, DIRECTION which, unsigned char * buf, int bufsize, int delim, int to){
|
||||||
int c;
|
int c;
|
||||||
int i=0;
|
int i=0;
|
||||||
if(bufsize < 1) return 0;
|
|
||||||
c = (which)?sockgetcharsrv(param, to, 0):sockgetcharcli(param, to, 0);
|
while(i < bufsize && (c = (which)?sockgetcharsrv(param, to, 0):sockgetcharcli(param, to, 0)) != EOF){
|
||||||
if (c == EOF) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
do {
|
|
||||||
buf[i++] = c;
|
buf[i++] = c;
|
||||||
if(delim != EOF && c == delim) break;
|
if(delim != EOF && c == delim) break;
|
||||||
}while(i < bufsize && (c = (which)?sockgetcharsrv(param, to, 0):sockgetcharcli(param, to, 0)) != EOF);
|
}
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user