diff --git a/src/3proxy.c b/src/3proxy.c index 977814d..e3c4a80 100644 --- a/src/3proxy.c +++ b/src/3proxy.c @@ -45,12 +45,7 @@ struct counter_header { } cheader = {"3CF", (time_t)0}; struct counter_record { -#ifndef NOPSTDINT uint64_t traf64; -#else - unsigned long traf; - unsigned long trafgb; -#endif time_t cleared; time_t updated; } crecord; @@ -469,11 +464,7 @@ void dumpcounters(struct trafcount *tlin, int counterd){ if(cfp){ for(tl = tlin; cfp && tl; tl = tl->next){ if(tl->type >= conf.countertype) -#ifndef NOPSTDINT fprintf(cfp, "%05d %020"PRINTF_INT64_MODIFIER"u%s%s\n", tl->number, tl->traf64, tl->comment?" #" : "", tl->comment? tl->comment : ""); -#else - fprintf(cfp, "%05d %010lu %010lu%s%s\n", tl->number, tl->trafgb, tl->traf, tl->comment?" #" : "", tl->comment? tl->comment : ""); -#endif } fclose(cfp); } @@ -488,24 +479,14 @@ void dumpcounters(struct trafcount *tlin, int counterd){ lseek(counterd, sizeof(struct counter_header) + (tl->number - 1) * sizeof(struct counter_record), SEEK_SET); -#ifndef NOPSTDINT crecord.traf64 = tl->traf64; -#else - crecord.traf = tl->traf; - crecord.trafgb = tl->trafgb; -#endif crecord.cleared = tl->cleared; crecord.updated = tl->updated; write(counterd, &crecord, sizeof(struct counter_record)); } if(tl->type!=NEVER && timechanged(tl->cleared, conf.time, tl->type)){ tl->cleared = conf.time; -#ifndef NOPSTDINT tl->traf64 = 0; -#else - tl->traf = 0; - tl->trafgb = 0; -#endif } } } @@ -1551,14 +1532,8 @@ static int h_ace(int argc, unsigned char **argv){ sscanf((char *)argv[1], "%u", &tl->number); sscanf((char *)argv[3], "%lu", &lim); tl->type = getrotate(*argv[2]); -#ifndef NOPSTDINT tl->traflim64 = ((uint64_t)lim)*(1024*1024); if(!tl->traflim64) { -#else - tl->traflimgb = (lim/(1024*4)); - tl->traflim = ((lim - (tl->traflimgb*(1024*4)))*(1024*1024)); - if(!tl->traflim && !tl->traflimgb) { -#endif fprintf(stderr, "Wrong traffic limit specified, line %d\n", linenum); return(6); } @@ -1568,12 +1543,7 @@ static int h_ace(int argc, unsigned char **argv){ SEEK_SET); memset(&crecord, 0, sizeof(struct counter_record)); read(conf.counterd, &crecord, sizeof(struct counter_record)); -#ifndef NOPSTDINT tl->traf64 = crecord.traf64; -#else - tl->traf = crecord.traf; - tl->trafgb = crecord.trafgb; -#endif tl->cleared = crecord.cleared; tl->updated = crecord.updated; #ifdef _MAX__TIME64_T diff --git a/src/auth.c b/src/auth.c index b2a9d44..93b24f5 100644 --- a/src/auth.c +++ b/src/auth.c @@ -115,11 +115,7 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, unsigned l len += sprintf((char *)buf + len, "\r\n"); if(socksend(param->remsock, buf, len, conf.timeouts[CHAIN_TO]) != (int)strlen((char *)buf)) return 31; -#ifndef NOPSTDINT param->statssrv64+=len; -#else - param->statssrv+=len; -#endif param->nwrites++; if((res = sockgetlinebuf(param, SERVER,buf,13,'\n',conf.timeouts[CHAIN_TO])) < 13) return 32; @@ -156,11 +152,7 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, unsigned l if(socksend(param->remsock, buf, len, conf.timeouts[CHAIN_TO]) < len){ return 41; } -#ifndef NOPSTDINT param->statssrv64+=len; -#else - param->statssrv+=len; -#endif param->nwrites++; if((len = sockgetlinebuf(param, SERVER, buf, (redir->type == R_SOCKS4B)? 3:8, EOF, conf.timeouts[CHAIN_TO])) != ((redir->type == R_SOCKS4B)? 3:8)){ return 42; @@ -183,11 +175,7 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, unsigned l if(socksend(param->remsock, buf, 3, conf.timeouts[CHAIN_TO]) != 3){ return 51; } -#ifndef NOPSTDINT param->statssrv64+=len; -#else - param->statssrv+=len; -#endif param->nwrites++; if(sockgetlinebuf(param, SERVER, buf, 2, EOF, conf.timeouts[CHAIN_TO]) != 2){ return 52; @@ -209,11 +197,7 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, unsigned l if(socksend(param->remsock, buf, inbuf, conf.timeouts[CHAIN_TO]) != inbuf){ return 51; } -#ifndef NOPSTDINT param->statssrv64+=inbuf; -#else - param->statssrv+=inbuf; -#endif param->nwrites++; if(sockgetlinebuf(param, SERVER, buf, 2, EOF, 60) != 2){ return 55; @@ -243,11 +227,7 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, unsigned l if(socksend(param->remsock, buf, len, conf.timeouts[CHAIN_TO]) != len){ return 51; } -#ifndef NOPSTDINT param->statssrv64+=len; -#else - param->statssrv+=len; -#endif param->nwrites++; if(sockgetlinebuf(param, SERVER, buf, 4, EOF, conf.timeouts[CHAIN_TO]) != 4){ return 57; @@ -561,7 +541,6 @@ unsigned bandlimitfunc(struct clientparam *param, unsigned nbytesin, unsigned nb void trafcountfunc(struct clientparam *param){ struct trafcount * tc; - unsigned long val; int countout = 0; pthread_mutex_lock(&tc_mutex); @@ -573,13 +552,7 @@ void trafcountfunc(struct clientparam *param){ countout = 1; continue; } -#ifndef NOPSTDINT tc->traf64 += param->statssrv64; -#else - val = tc->traf + param->statssrv; - if(val < tc->traf) tc->trafgb++; - tc->traf = val; -#endif time(&t); tc->updated = t; } @@ -591,13 +564,7 @@ void trafcountfunc(struct clientparam *param){ if(tc->ace->action != COUNTOUT) { continue; } -#ifndef NOPSTDINT tc->traf64 += param->statscli64; -#else - val = tc->traf + param->statscli; - if(val < tc->traf) tc->trafgb++; - tc->traf = val; -#endif time(&t); tc->updated = t; } @@ -624,21 +591,9 @@ int alwaysauth(struct clientparam * param){ continue; } -#ifndef NOPSTDINT if(tc->traflim64 <= tc->traf64) return 10; param->trafcountfunc = conf.trafcountfunc; param->maxtrafin64 = tc->traflim64 - tc->traf64; -#else - if((tc->traflimgb < tc->trafgb) || - ((tc->traflimgb == tc->trafgb) && (tc->traflim < tc->traf)) - ) return 10; - param->trafcountfunc = conf.trafcountfunc; - if(tc->traflimgb - tc->trafgb < 1 || ((tc->traflimgb - tc->trafgb) == 1 && tc->traf > tc->traflim)){ - unsigned maxtraf = tc->traflim - tc->traf; - if(!param->maxtrafin || param->maxtrafin > maxtraf) param->maxtrafin = maxtraf; - } - if((tc->trafgb > tc->traflimgb) || (tc->trafgb == tc->traflimgb && tc->traf >= tc->traflim)) param->maxtrafin = 1; -#endif } } if(countout)for(tc = conf.trafcounter; tc; tc = tc->next) { @@ -649,21 +604,9 @@ int alwaysauth(struct clientparam * param){ continue; } -#ifndef NOPSTDINT if(tc->traflim64 <= tc->traf64) return 10; param->trafcountfunc = conf.trafcountfunc; param->maxtrafout64 = tc->traflim64 - tc->traf64; -#else - if((tc->traflimgb < tc->trafgb) || - ((tc->traflimgb == tc->trafgb) && (tc->traflim < tc->traf)) - ) return 10; - param->trafcountfunc = conf.trafcountfunc; - if(tc->traflimgb - tc->trafgb < 1 || ((tc->traflimgb - tc->trafgb) == 1 && tc->traf > tc->traflim)){ - unsigned maxtraf = tc->traflim - tc->traf; - if(!param->maxtrafout || param->maxtrafout > maxtraf) param->maxtrafout = maxtraf; - } - if((tc->trafgb > tc->traflimgb) || (tc->trafgb == tc->traflimgb && tc->traf >= tc->traflim)) param->maxtrafout = 1; -#endif } } @@ -1129,20 +1072,12 @@ unsigned long udpresolve(unsigned char * name, unsigned *retttl, struct clientpa so._closesocket(sock); continue; } -#ifndef NOPSTDINT if(param) param->statscli64 += len; -#else - if(param) param->statscli += len; -#endif len = sockrecvfrom(sock, sinsp, buf, 4096, 15000); so._shutdown(sock, SHUT_RDWR); so._closesocket(sock); if(len <= 13) continue; -#ifndef NOPSTDINT if(param) param->statssrv64 += len; -#else - if(param) param->statssrv += len; -#endif if(*(unsigned short *)buf != nquery)continue; if((na = buf[7] + (((unsigned short)buf[6])<<8)) < 1) { return 0; diff --git a/src/common.c b/src/common.c index 694c973..b2509a3 100644 --- a/src/common.c +++ b/src/common.c @@ -287,11 +287,7 @@ void clearstat(struct clientparam * param) { param->time_start = (time_t)tv.tv_sec; param->msec_start = (tv.tv_usec / 1000); #endif -#ifndef NOPSTDINT param->statscli64 = param->statssrv64 = param->nreads = param->nwrites = -#else - param->statscli = param->statssrv = param->nreads = param->nwrites = -#endif param->nconnects = 0; } @@ -382,17 +378,10 @@ int dobuf2(struct clientparam * param, unsigned char * buf, const unsigned char i+=10; break; case 'b': -#ifndef NOPSTDINT i+=sprintf((char *)buf+i, "%u", delay?(unsigned)(param->statscli64 * 1000./delay):0); break; case 'B': i+=sprintf((char *)buf+i, "%u", delay?(unsigned)(param->statssrv64 * 1000./delay):0); -#else - i+=sprintf((char *)buf+i, "%u", delay?(unsigned)(param->statscli * 1000./delay):0); - break; - case 'B': - i+=sprintf((char *)buf+i, "%u", delay?(unsigned)(param->statssrv * 1000./delay):0); -#endif break; case 'D': i+=sprintf((char *)buf+i, "%u", delay); @@ -489,19 +478,11 @@ int dobuf2(struct clientparam * param, unsigned char * buf, const unsigned char i += (int)strlen((char *)buf+i); break; case 'I': -#ifndef NOPSTDINT sprintf((char *)buf+i, "%"PRINTF_INT64_MODIFIER"u", param->statssrv64); i += (int)strlen((char *)buf+i); break; case 'O': sprintf((char *)buf+i, "%"PRINTF_INT64_MODIFIER"u", param->statscli64); -#else - sprintf((char *)buf+i, "%lu", param->statssrv); - i += (int)strlen((char *)buf+i); - break; - case 'O': - sprintf((char *)buf+i, "%lu", param->statscli); -#endif i += (int)strlen((char *)buf+i); break; case 'h': diff --git a/src/datatypes.c b/src/datatypes.c index a99f7d5..554ab8f 100644 --- a/src/datatypes.c +++ b/src/datatypes.c @@ -8,12 +8,10 @@ #include "proxy.h" -#ifndef NOPSTDINT static void pr_unsigned64(struct node *node, CBFUNC cbf, void*cb){ char buf[32]; if(node->value)(*cbf)(cb, buf, sprintf(buf, "%"PRINTF_INT64_MODIFIER"u", *(uint64_t *)node->value)); } -#endif static void pr_integer(struct node *node, CBFUNC cbf, void*cb){ char buf[16]; @@ -453,7 +451,6 @@ static void * ef_trafcounter_type(struct node * node){ return &((struct trafcount *)node->value) -> type; } -#ifndef NOPSTDINT static void * ef_trafcounter_traffic64(struct node * node){ return &((struct trafcount *)node->value) -> traf64; } @@ -476,33 +473,6 @@ static void * ef_client_bytesout64(struct node * node){ return &((struct clientparam *)node->value) -> statscli64; } -#else - -static void * ef_trafcounter_traffic(struct node * node){ - return &((struct trafcount *)node->value) -> traf; -} -static void * ef_trafcounter_limit(struct node * node){ - return &((struct trafcount *)node->value) -> traflim; -} -static void * ef_client_maxtrafin(struct node * node){ - return &((struct clientparam *)node->value) -> maxtrafin; -} -static void * ef_client_maxtrafout(struct node * node){ - return &((struct clientparam *)node->value) -> maxtrafout; -} - -static void * ef_client_bytesin(struct node * node){ - return &((struct clientparam *)node->value) -> statssrv; -} - -static void * ef_client_bytesout(struct node * node){ - return &((struct clientparam *)node->value) -> statscli; -} - - -#endif - - static void * ef_trafcounter_cleared(struct node * node){ return &((struct trafcount *)node->value) -> cleared; } @@ -777,13 +747,8 @@ static struct property prop_trafcounter[] = { {prop_trafcounter + 4, "type", ef_trafcounter_type, TYPE_ROTATION, "rotation type"}, -#ifndef NOPSTDINT {prop_trafcounter + 5, "traffic", ef_trafcounter_traffic64, TYPE_UNSIGNED64, "counter value"}, {prop_trafcounter + 6, "limit", ef_trafcounter_limit64, TYPE_UNSIGNED64, "counter limit"}, -#else - {prop_trafcounter + 5, "traffic", ef_trafcounter_traffic, TYPE_TRAFFIC, "counter value"}, - {prop_trafcounter + 6, "limit", ef_trafcounter_limit, TYPE_TRAFFIC, "counter limit"}, -#endif {prop_trafcounter + 7, "cleared", ef_trafcounter_cleared, TYPE_DATETIME, "last rotated"}, {prop_trafcounter + 8, "updated", ef_trafcounter_updated, TYPE_DATETIME, "last updated"}, {prop_trafcounter + 9, "comment", ef_trafcounter_comment, TYPE_STRING, "counter comment"}, @@ -835,17 +800,10 @@ static struct property prop_client[] = { {prop_client + 15, "srvport", ef_client_srvport, TYPE_PORT, "target server port"}, {prop_client + 16, "reqip", ef_client_reqip, TYPE_IP, "requested server ip"}, {prop_client + 17, "reqport", ef_client_reqport, TYPE_PORT, "requested server port"}, -#ifndef NOPSTDINT {prop_client + 18, "bytesin", ef_client_bytesin64, TYPE_UNSIGNED64, "bytes from server to client"}, {prop_client + 19, "bytesout", ef_client_bytesout64, TYPE_UNSIGNED64, "bytes from client to server"}, {prop_client + 20, "maxtrafin", ef_client_maxtrafin64, TYPE_UNSIGNED64, "maximum traffic allowed for download"}, {prop_client + 21, "maxtrafout", ef_client_maxtrafout64, TYPE_UNSIGNED64, "maximum traffic allowed for upload"}, -#else - {prop_client + 18, "bytesin", ef_client_bytesin, TYPE_UNSIGNED, "bytes from server to client"}, - {prop_client + 19, "bytesout", ef_client_bytesout, TYPE_UNSIGNED, "bytes from client to server"}, - {prop_client + 20, "maxtrafin", ef_client_maxtrafin, TYPE_UNSIGNED, "maximum traffic allowed for download"}, - {prop_client + 21, "maxtrafout", ef_client_maxtrafout, TYPE_UNSIGNED, "maximum traffic allowed for upload"}, -#endif {prop_client + 22, "pwtype", ef_client_pwtype, TYPE_INTEGER, "type of client password"}, {NULL, "next", ef_client_next, TYPE_CLIENT, "next"} diff --git a/src/dnspr.c b/src/dnspr.c index 661a668..6612d6f 100644 --- a/src/dnspr.c +++ b/src/dnspr.c @@ -147,21 +147,13 @@ void * dnsprchild(struct clientparam* param) { if(socksendto(param->remsock, ¶m->sins, buf, i, conf.timeouts[SINGLEBYTE_L]*1000) != i){ RETURN(820); } -#ifndef NOPSTDINT param->statscli64 += i; -#else - param->statscli += i; -#endif param->nwrites++; len = sockrecvfrom(param->remsock, ¶m->sins, buf, BUFSIZE, 15000); if(len <= 13) { RETURN(821); } -#ifndef NOPSTDINT param->statssrv64 += len; -#else - param->statssrv += len; -#endif param->nreads++; if(buf[6] || buf[7]){ if(socksendto(param->clisock, ¶m->sinc, buf, len, conf.timeouts[SINGLEBYTE_L]*1000) != len){ diff --git a/src/ftppr.c b/src/ftppr.c index 28d695e..4feeb7b 100644 --- a/src/ftppr.c +++ b/src/ftppr.c @@ -276,11 +276,7 @@ param->srv->logfunc(param,buf); buf[i++] = '\r'; buf[i++] = '\n'; if(socksend(param->remsock, buf, i, conf.timeouts[STRING_S])!=i) {RETURN (811);} -#ifndef NOPSTDINT param->statscli64+=(i); -#else - param->statscli+=(i); -#endif param->nwrites++; while((i = sockgetlinebuf(param, SERVER, buf, BUFSIZE, '\n', conf.timeouts[STRING_L])) > 0){ if(socksend(param->ctrlsock, buf, i, conf.timeouts[STRING_S])!=i) {RETURN (812);} @@ -291,15 +287,9 @@ param->srv->logfunc(param,buf); } sasize = sizeof(struct sockaddr_in); if(so._getpeername(param->ctrlsock, (struct sockaddr *)¶m->sinc, &sasize)){RETURN(819);} -#ifndef NOPSTDINT if(req && (param->statscli64 || param->statssrv64)){ (*param->srv->logfunc)(param, (unsigned char *)req); } -#else - if(req && (param->statscli || param->statssrv)){ - (*param->srv->logfunc)(param, (unsigned char *)req); - } -#endif } CLEANRET: @@ -318,11 +308,7 @@ CLEANRET: } sasize = sizeof(struct sockaddr_in); so._getpeername(param->ctrlsock, (struct sockaddr *)¶m->sinc, &sasize); -#ifndef NOPSTDINT if(param->res != 0 || param->statscli64 || param->statssrv64 ){ -#else - if(param->res != 0 || param->statscli || param->statssrv ){ -#endif (*param->srv->logfunc)(param, (unsigned char *)((req && (param->res > 802))? req:NULL)); } if(req) myfree(req); diff --git a/src/icqpr.c b/src/icqpr.c index e1a315d..ee6808a 100644 --- a/src/icqpr.c +++ b/src/icqpr.c @@ -109,11 +109,7 @@ static void addbuffer(int increment, struct clientparam * param, unsigned char * if(len > 0) { *length_p += len; param->nreads++; -#ifndef NOPSTDINT param->statssrv64 += len; -#else - param->statssrv += len; -#endif } return; } @@ -441,31 +437,17 @@ void * icqprchild(struct clientparam* param) { if(greet){ if(socksend(param->remsock, tmpsend, 10, conf.timeouts[STRING_S])!=10) {RETURN (1105);} -#ifndef NOPSTDINT param->statscli64 += 10; -#else - param->statscli += 10; -#endif } if(readflap(param, SERVER, tmpsend, 1024)) {RETURN (1111);} -#ifndef NOPSTDINT param->statssrv64 += (ntohs(((struct flap_header *)tmpsend)->size) + 6); -#else - param->statssrv += (ntohs(((struct flap_header *)tmpsend)->size) + 6); -#endif mystate.srvseq = ntohs(((struct flap_header *)tmpsend)->seq) + 1; mystate.seq = 1; len = ntohs(flap->size) + 6; if((res=handledatfltcli(param, &buf, &buflen, offset, &len))!=PASS) RETURN(res); if(socksend(param->remsock, buf+offset, len, conf.timeouts[STRING_S])!=(ntohs(flap->size)+6)) {RETURN (1106);} offset = 0; -#ifndef NOPSTDINT param->statscli64 += len; -#else - param->statscli += len; -#endif - - if(logintype == ICQMD5) { if(readflap(param, SERVER, buf, 65550)) {RETURN (1112);} @@ -481,11 +463,7 @@ void * icqprchild(struct clientparam* param) { len = ntohs(flap->size) + 6; if((res=handledatfltcli(param, &buf, &buflen, offset, &len))!=PASS) RETURN(res); if(socksend(param->remsock, buf+offset, len, conf.timeouts[STRING_S])!=len) {RETURN (1115);} -#ifndef NOPSTDINT param->statscli64 += len; -#else - param->statscli += len; -#endif offset = 0; } if(logintype != ICQCOOKIE) { diff --git a/src/msnpr.c b/src/msnpr.c index 1ff1391..31895b4 100644 --- a/src/msnpr.c +++ b/src/msnpr.c @@ -173,22 +173,14 @@ void * msnprchild(struct clientparam* param) { if(!sec){ len = (int)strlen(verstr); if(socksend(param->remsock, verstr, len, conf.timeouts[STRING_S])!= len) {RETURN (1207);} -#ifndef NOPSTDINT param->statscli64 += len; -#else - param->statscli += len; -#endif myfree(verstr); verstr = mystrdup(buf); len = sockgetlinebuf(param, SERVER, buf, 240, '\n', conf.timeouts[STRING_S]); if(len < 10) RETURN(1208); -#ifndef NOPSTDINT param->statssrv64 += len; -#else - param->statssrv += len; -#endif strcpy(buf, verstr); } @@ -198,11 +190,7 @@ void * msnprchild(struct clientparam* param) { if(socksend(param->remsock, buf, len, conf.timeouts[STRING_S])!= len) {RETURN (1207);} -#ifndef NOPSTDINT param->statscli64 += len; -#else - param->statscli += len; -#endif if(sec){ RETURN(sockmap(param, conf.timeouts[CONNECTION_L])); diff --git a/src/pop3p.c b/src/pop3p.c index f5ac9b7..c3a7ef6 100644 --- a/src/pop3p.c +++ b/src/pop3p.c @@ -43,11 +43,7 @@ void * pop3pchild(struct clientparam* param) { socksend(param->remsock, param->extusername, (int)strlen((char *)param->extusername), conf.timeouts[STRING_S]) <= 0 || socksend(param->remsock, (unsigned char *)"\r\n", 2, conf.timeouts[STRING_S])!=2) {RETURN(623);} -#ifndef NOPSTDINT param->statscli64 += (uint64_t)(strlen((char *)param->extusername) + 7); -#else - param->statscli += (int)(strlen((char *)param->extusername) + 7); -#endif param->nwrites++; RETURN (sockmap(param, 180)); CLEANRET: diff --git a/src/proxy.c b/src/proxy.c index b09176b..36f201b 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -217,11 +217,7 @@ void * proxychild(struct clientparam* param) { unsigned char *ftpbase=NULL; unsigned char username[1024]; int keepalive = 0; -#ifndef NOPSTDINT uint64_t contentlength64 = 0; -#else - unsigned long contentlength = 0; -#endif int hascontent =0; int isconnect = 0; int redirect = 0; @@ -392,7 +388,6 @@ for(;;){ while( (i = sockgetlinebuf(param, CLIENT, buf, BUFSIZE - 1, '\n', conf.timeouts[STRING_S])) > 2){ if(i> 15 && (!strncasecmp((char *)(buf), "content-length", 14))){ buf[i]=0; -#ifndef NOPSTDINT sscanf((char *)buf + 15, "%"PRINTF_INT64_MODIFIER"u", &contentlength64); } } @@ -401,16 +396,6 @@ for(;;){ contentlength64-=i; } contentlength64 = 0; -#else - sscanf((char *)buf + 15, "%lu", &contentlength); - } - } - while( contentlength > 0 && (i = sockgetlinebuf(param, CLIENT, buf, (BUFSIZE < contentlength)? BUFSIZE - 1:contentlength, '\n', conf.timeouts[STRING_S])) > 0){ - if ((unsigned long)i > contentlength) break; - contentlength-=i; - } - contentlength = 0; -#endif if(param->password)myfree(param->password); param->password = myalloc(32); param->pwtype = 2; @@ -507,19 +492,11 @@ for(;;){ if(!sb)continue; ++sb; while(isspace(*sb))sb++; -#ifndef NOPSTDINT sscanf(sb, "%"PRINTF_INT64_MODIFIER"u",&contentlength64); if(param->maxtrafout64 && (param->maxtrafout64 < param->statscli64 || contentlength64 > param->maxtrafout64 - param->statscli64)){ RETURN(10); } if(param->ndatfilterscli > 0 && contentlength64 > 0) continue; -#else - sscanf(sb, "%lu",&contentlength); - if(param->maxtrafout && (param->maxtrafout < param->statscli || (unsigned)contentlength > param->maxtrafout - param->statscli)){ - RETURN(10); - } - if(param->ndatfilterscli > 0 && contentlength > 0) continue; -#endif } inbuf += i; if((bufsize - inbuf) < LINESIZE){ @@ -550,34 +527,19 @@ for(;;){ RETURN(0); } if(action != PASS) RETURN(517); -#ifndef NOPSTDINT if(param->ndatfilterscli > 0 && contentlength64 > 0){ uint64_t newlen64; newlen64 = sockfillbuffcli(param, (unsigned long)contentlength64, CONNECTION_S); if(newlen64 == contentlength64) { -#else - if(param->ndatfilterscli > 0 && contentlength > 0){ - unsigned long newlen; - newlen = sockfillbuffcli(param, contentlength, CONNECTION_S); - if(newlen == contentlength) { -#endif action = handledatfltcli(param, ¶m->clibuf, ¶m->clibufsize, 0, ¶m->cliinbuf); if(action == HANDLED){ RETURN(0); } if(action != PASS) RETURN(517); -#ifndef NOPSTDINT contentlength64 = param->cliinbuf; -#else - contentlength = param->cliinbuf; -#endif param->ndatfilterscli = 0; } -#ifndef NOPSTDINT sprintf((char*)buf+strlen((char *)buf), "Content-Length: %"PRINTF_INT64_MODIFIER"u\r\n", contentlength64); -#else - sprintf((char*)buf+strlen((char *)buf), "Content-Length: %lu\r\n", contentlength); -#endif } #endif @@ -657,11 +619,7 @@ for(;;){ socksend(param->clisock, (unsigned char *)proxy_stringtable[8], (int)strlen(proxy_stringtable[8]), conf.timeouts[STRING_S]); s = param->remsock; param->remsock = ftps; -#ifndef NOPSTDINT if((param->operation == FTP_PUT) && (contentlength64 > 0)) param->waitclient64 = contentlength64; -#else - if((param->operation == FTP_PUT) && (contentlength > 0)) param->waitclient = contentlength; -#endif res = sockmap(param, conf.timeouts[CONNECTION_L]); if (res == 99) res = 0; so._closesocket(ftps); @@ -863,11 +821,7 @@ for(;;){ if(socksend(param->remsock, req , (res = (int)strlen((char *)req)), conf.timeouts[STRING_L]) != res) { RETURN(518); } -#ifndef NOPSTDINT param->statscli64 += res; -#else - param->statscli += res; -#endif param->nwrites++; } inbuf = 0; @@ -899,16 +853,11 @@ for(;;){ if ((res = socksend(param->remsock, buf+reqlen, (int)strlen((char *)buf+reqlen), conf.timeouts[STRING_S])) != (int)strlen((char *)buf+reqlen)) { RETURN(518); } -#ifndef NOPSTDINT param->statscli64 += res; -#else - param->statscli += res; -#endif param->nwrites++; if(param->bandlimfunc) { sleeptime = param->bandlimfunc(param, 0, (int)strlen((char *)buf)); } -#ifndef NOPSTDINT if(contentlength64 > 0){ param->nolongdatfilter = 0; param->waitclient64 = contentlength64; @@ -919,18 +868,6 @@ for(;;){ } } contentlength64 = 0; -#else - if(contentlength > 0){ - param->nolongdatfilter = 0; - param->waitclient = contentlength; - res = sockmap(param, conf.timeouts[CONNECTION_S]); - param->waitclient = 0; - if(res != 99) { - RETURN(res); - } - } - contentlength = 0; -#endif inbuf = 0; ckeepalive = keepalive; res = 0; @@ -963,21 +900,13 @@ for(;;){ if(!sb)continue; ++sb; while(isspace(*sb))sb++; -#ifndef NOPSTDINT sscanf(sb, "%"PRINTF_INT64_MODIFIER"u", &contentlength64); -#else - sscanf(sb, "%lu", &contentlength); -#endif hascontent = 1; if(param->unsafefilter && param->ndatfilterssrv > 0) { hascontent = 2; continue; } -#ifndef NOPSTDINT if(param->maxtrafin64 && (param->maxtrafin64 < param->statssrv64 || contentlength64 + param->statssrv64 > param->maxtrafin64)){ -#else - if(param->maxtrafin && (param->maxtrafin < param->statssrv || (unsigned)contentlength > param->maxtrafin - param->statssrv)){ -#endif RETURN(10); } } @@ -1006,11 +935,7 @@ for(;;){ } if((res == 304 || res == 204) && !hascontent){ hascontent = 1; -#ifndef NOPSTDINT contentlength64 = 0; -#else - contentlength = 0; -#endif } if(param->bandlimfunc) { int st1; @@ -1034,7 +959,6 @@ for(;;){ param->nolongdatfilter = 0; -#ifndef NOPSTDINT if (conf.filtermaxsize && contentlength64 > (uint64_t)conf.filtermaxsize) { param->nolongdatfilter = 1; } @@ -1054,27 +978,6 @@ for(;;){ } } if (contentlength64 > 0 && hascontent != 1) ckeepalive = 0; -#else - if (conf.filtermaxsize && contentlength > (unsigned long)conf.filtermaxsize) { - param->nolongdatfilter = 1; - } - else if(param->unsafefilter && param->ndatfilterssrv > 0 && contentlength > 0 && param->operation != HTTP_HEAD && res != 204 && res != 304){ - unsigned long newlen; - newlen = sockfillbuffsrv(param, (unsigned long) contentlength, CONNECTION_S); - if(newlen == contentlength) { - action = handledatfltsrv(param, ¶m->srvbuf, ¶m->srvbufsize, 0, ¶m->srvinbuf); - param->nolongdatfilter = 1; - if(action == HANDLED){ - RETURN(0); - } - if(action != PASS) RETURN(517); - contentlength = param->srvinbuf; - sprintf((char*)buf+strlen((char *)buf), "Content-Length: %lu\r\n", contentlength); - hascontent = 1; - } - } - if (contentlength > 0 && hascontent != 1) ckeepalive = 0; -#endif #else #endif if(!isconnect || param->operation){ @@ -1093,11 +996,7 @@ for(;;){ RETURN(521); } } -#ifndef NOPSTDINT if((param->chunked || contentlength64 > 0) && param->operation != HTTP_HEAD && res != 204 && res != 304) { -#else - if((param->chunked || contentlength > 0) && param->operation != HTTP_HEAD && res != 204 && res != 304) { -#endif do { if(param->chunked){ char smallbuf[32]; @@ -1122,32 +1021,18 @@ for(;;){ break; } smallbuf[i] = 0; -#ifndef NOPSTDINT contentlength64 = 0; sscanf(smallbuf, "%"PRINTF_INT64_MODIFIER"x", &contentlength64); if(contentlength64 == 0) { -#else - contentlength = 0; - sscanf(smallbuf, "%lx", &contentlength); - if(contentlength == 0) { -#endif param->chunked = 2; } } if(param->chunked != 2){ -#ifndef NOPSTDINT param->waitserver64 = contentlength64; -#else - param->waitserver = contentlength; -#endif if((res = sockmap(param, conf.timeouts[CONNECTION_S])) != 98){ RETURN(res); } -#ifndef NOPSTDINT param->waitserver64 = 0; -#else - param->waitserver = 0; -#endif } } while(param->chunked); } @@ -1160,11 +1045,7 @@ for(;;){ else if(!hascontent && !param->chunked) { RETURN(sockmap(param, conf.timeouts[CONNECTION_S])); } -#ifndef NOPSTDINT contentlength64 = 0; -#else - contentlength = 0; -#endif REQUESTEND: if((!ckeepalive || !keepalive) && param->remsock != INVALID_SOCKET){ diff --git a/src/smtpp.c b/src/smtpp.c index f736119..8c17e73 100644 --- a/src/smtpp.c +++ b/src/smtpp.c @@ -191,11 +191,7 @@ void * smtppchild(struct clientparam* param) { ul = param->extip; i = sprintf(buf, "EHLO [%lu.%lu.%lu.%lu]\r\n", ((ul&0xFF000000)>>24), ((ul&0x00FF0000)>>16), ((ul&0x0000FF00)>>8), ((ul&0x000000FF))); if(socksend(param->remsock, buf, i, conf.timeouts[STRING_S])!= i) {RETURN(673);} -#ifndef NOPSTDINT param->statscli64+=i; -#else - param->statscli+=i; -#endif param->nwrites++; login = 0; do { @@ -213,42 +209,26 @@ void * smtppchild(struct clientparam* param) { } if ((login & 1)) { socksend(param->remsock, "AUTH LOGIN\r\n", 12, conf.timeouts[STRING_S]); -#ifndef NOPSTDINT param->statscli64+=12; -#else - param->statscli+=12; -#endif param->nwrites++; i = sockgetlinebuf(param, SERVER, buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L]); if(i<4 || strncasecmp((char *)buf, "334", 3)) {RETURN(680);} en64(param->extusername, buf, (int)strlen(param->extusername)); socksend(param->remsock, buf, (int)strlen(buf), conf.timeouts[STRING_S]); socksend(param->remsock, "\r\n", 2, conf.timeouts[STRING_S]); -#ifndef NOPSTDINT param->statscli64+=(i+2); -#else - param->statscli+=(i+2); -#endif param->nwrites+=2; i = sockgetlinebuf(param, SERVER, buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L]); if(i<4 || strncasecmp((char *)buf, "334", 3)) {RETURN(681);} en64(param->extpassword, buf, (int)strlen(param->extpassword)); socksend(param->remsock, buf, (int)strlen(buf), conf.timeouts[STRING_S]); socksend(param->remsock, "\r\n", 2, conf.timeouts[STRING_S]); -#ifndef NOPSTDINT param->statscli64+=(i+2); -#else - param->statscli+=(i+2); -#endif param->nwrites+=2; } else if((login & 2)){ socksend(param->remsock, "AUTH PLAIN\r\n", 12, conf.timeouts[STRING_S]); -#ifndef NOPSTDINT param->statscli64+=(12); -#else - param->statscli+=(12); -#endif param->nwrites++; i = sockgetlinebuf(param, SERVER, buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L]); if(i<4 || strncasecmp((char *)buf, "334", 3)) {RETURN(682);} @@ -263,11 +243,7 @@ void * smtppchild(struct clientparam* param) { i = (int)strlen(buf); socksend(param->remsock, buf, i, conf.timeouts[STRING_S]); socksend(param->remsock, "\r\n", 2, conf.timeouts[STRING_S]); -#ifndef NOPSTDINT param->statscli64+=(i+2); -#else - param->statscli+=(i+2); -#endif param->nwrites+=2; } if(command) { diff --git a/src/sockgetchar.c b/src/sockgetchar.c index c507b6b..0041fdf 100644 --- a/src/sockgetchar.c +++ b/src/sockgetchar.c @@ -126,11 +126,7 @@ int sockfillbuffsrv(struct clientparam * param, unsigned long size, int timeosec if((len = sockrecvfrom(param->remsock, ¶m->sinc, param->srvbuf + param->srvinbuf, (param->srvbufsize - param->srvinbuf) < size? param->srvbufsize - param->srvinbuf:size, timeosec*1000)) > 0){ param->srvinbuf += len; param->nreads++; -#ifndef NOPSTDINT param->statssrv64 += len; -#else - param->statssrv += len; -#endif } return param->srvinbuf; } @@ -156,11 +152,7 @@ int sockgetcharsrv(struct clientparam * param, int timeosec, int timeousec){ param->srvinbuf = len; param->srvoffset = 1; param->nreads++; -#ifndef NOPSTDINT param->statssrv64 += len; -#else - param->statssrv += len; -#endif return (int)*param->srvbuf; } diff --git a/src/sockmap.c b/src/sockmap.c index a039322..d2a2eca 100644 --- a/src/sockmap.c +++ b/src/sockmap.c @@ -13,11 +13,7 @@ int sockmap(struct clientparam * param, int timeo){ int res=0; -#ifndef NOPSTDINT uint64_t sent=0, received=0; -#else - unsigned sent=0, received=0; -#endif SASIZETYPE sasize; struct pollfd fds[2]; int sleeptime = 0, stop = 0; @@ -36,20 +32,12 @@ int sockmap(struct clientparam * param, int timeo){ #if DEBUGLEVEL > 2 (*param->srv->logfunc)(param, "Starting sockets mapping"); #endif -#ifndef NOPSTDINT if(!param->waitclient64){ -#else - if(!param->waitclient){ -#endif if(!param->srvbuf && (!(param->srvbuf=myalloc(bufsize)) || !(param->srvbufsize = bufsize))){ return (21); } } -#ifndef NOPSTDINT if(!param->waitserver64){ -#else - if(!param->waitserver){ -#endif if(!param->clibuf && (!(param->clibuf=myalloc(bufsize)) || !(param->clibufsize = bufsize))){ return (21); } @@ -81,7 +69,6 @@ int sockmap(struct clientparam * param, int timeo){ while (!stop&&!conf.timetoexit){ sasize = sizeof(struct sockaddr_in); -#ifndef NOPSTDINT if((param->maxtrafin64 && param->statssrv64 >= param->maxtrafin64) || (param->maxtrafout64 && param->statscli64 >= param->maxtrafout64)){ return (10); } @@ -90,47 +77,25 @@ int sockmap(struct clientparam * param, int timeo){ (*param->srv->logfunc)(param, NULL); fds[0].events = fds[1].events = 0; if(param->srvinbuf > param->srvoffset && !param->waitclient64) { -#else - if((param->maxtrafin && param->statssrv >= param->maxtrafin) || (param->maxtrafout && param->statscli >= param->maxtrafout)){ - return (10); - } - if((param->srv->logdumpsrv && (param->statssrv > param->srv->logdumpsrv)) || - (param->srv->logdumpcli && (param->statscli > param->srv->logdumpcli))) - (*param->srv->logfunc)(param, NULL); - fds[0].events = fds[1].events = 0; - if(param->srvinbuf > param->srvoffset && !param->waitclient) { -#endif #if DEBUGLEVEL > 2 (*param->srv->logfunc)(param, "will send to client"); #endif fds[0].events |= POLLOUT; } -#ifndef NOPSTDINT if((param->srvbufsize - param->srvinbuf) > minsize && !param->waitclient64 && (!param->waitserver64 ||(received + param->srvinbuf - param->srvoffset < param->waitserver64))) { -#else - if((param->srvbufsize - param->srvinbuf) > minsize && !param->waitclient && (!param->waitserver ||(received + param->srvinbuf - param->srvoffset < param->waitserver))) { -#endif #if DEBUGLEVEL > 2 (*param->srv->logfunc)(param, "Will recv from server"); #endif fds[1].events |= POLLIN; } -#ifndef NOPSTDINT if(param->cliinbuf > param->clioffset && !param->waitserver64) { -#else - if(param->cliinbuf > param->clioffset && !param->waitserver) { -#endif #if DEBUGLEVEL > 2 (*param->srv->logfunc)(param, "Will send to server"); #endif fds[1].events |= POLLOUT; } -#ifndef NOPSTDINT if((param->clibufsize - param->cliinbuf) > minsize && !param->waitserver64 &&(!param->srv->singlepacket || param->service != S_UDPPM) ) { -#else - if((param->clibufsize - param->cliinbuf) > minsize && !param->waitserver &&(!param->srv->singlepacket || param->service != S_UDPPM) ) { -#endif #if DEBUGLEVEL > 2 (*param->srv->logfunc)(param, "Will recv from client"); #endif @@ -163,11 +128,7 @@ int sockmap(struct clientparam * param, int timeo){ if(param->bandlimfunc) { sleeptime = (*param->bandlimfunc)(param, param->srvinbuf - param->srvoffset, 0); } -#ifndef NOPSTDINT res = so._sendto(param->clisock, param->srvbuf + param->srvoffset,(!param->waitserver64 || (param->waitserver64 - received) > (param->srvinbuf - param->srvoffset))? param->srvinbuf - param->srvoffset : (int)(param->waitserver64 - received), 0, (struct sockaddr*)¶m->sinc, sasize); -#else - res = so._sendto(param->clisock, param->srvbuf + param->srvoffset,(!param->waitserver || ((unsigned)param->waitserver - received) > (param->srvinbuf - param->srvoffset))? param->srvinbuf - param->srvoffset : param->waitserver - received, 0, (struct sockaddr*)¶m->sinc, sasize); -#endif if(res < 0) { if(errno != EAGAIN) return 96; continue; @@ -175,11 +136,7 @@ int sockmap(struct clientparam * param, int timeo){ param->srvoffset += res; received += res; if(param->srvoffset == param->srvinbuf) param->srvoffset = param->srvinbuf = 0; -#ifndef NOPSTDINT if(param->waitserver64 && param->waitserver64<= received){ -#else - if(param->waitserver && param->waitserver<= received){ -#endif return (98); } if(param->service == S_UDPPM && param->srv->singlepacket) { @@ -196,11 +153,7 @@ int sockmap(struct clientparam * param, int timeo){ sl1 = (*param->bandlimfunc)(param, 0, param->cliinbuf - param->clioffset); if(sl1 > sleeptime) sleeptime = sl1; } -#ifndef NOPSTDINT res = so._sendto(param->remsock, param->clibuf + param->clioffset, (!param->waitclient64 || (param->waitclient64 - sent) > (param->cliinbuf - param->clioffset))? param->cliinbuf - param->clioffset : (int)(param->waitclient64 - sent), 0, (struct sockaddr*)¶m->sins, sasize); -#else - res = so._sendto(param->remsock, param->clibuf + param->clioffset, (!param->waitclient || ((unsigned)param->waitclient - sent) > (param->cliinbuf - param->clioffset))? param->cliinbuf - param->clioffset : param->waitclient - sent, 0, (struct sockaddr*)¶m->sins, sasize); -#endif if(res < 0) { if(errno != EAGAIN) return 97; continue; @@ -209,13 +162,8 @@ int sockmap(struct clientparam * param, int timeo){ if(param->clioffset == param->cliinbuf) param->clioffset = param->cliinbuf = 0; sent += res; param->nwrites++; -#ifndef NOPSTDINT param->statscli64 += res; if(param->waitclient64 && param->waitclient64<= sent) { -#else - param->statscli += res; - if(param->waitclient && param->waitclient<= sent) { -#endif return (99); } } @@ -267,11 +215,7 @@ int sockmap(struct clientparam * param, int timeo){ } param->srvinbuf += res; param->nreads++; -#ifndef NOPSTDINT param->statssrv64 += res; -#else - param->statssrv += res; -#endif if(!param->nolongdatfilter){ action = handledatfltsrv(param, ¶m->srvbuf, ¶m->srvbufsize, param->srvinbuf - res, ¶m->srvinbuf); if(action == HANDLED){ @@ -293,42 +237,26 @@ int sockmap(struct clientparam * param, int timeo){ #if DEBUGLEVEL > 2 (*param->srv->logfunc)(param, "finished with mapping"); #endif -#ifndef NOPSTDINT while(!param->waitclient64 && param->srvinbuf > param->srvoffset && param->clisock != INVALID_SOCKET){ -#else - while(!param->waitclient && param->srvinbuf > param->srvoffset && param->clisock != INVALID_SOCKET){ -#endif #if DEBUGLEVEL > 2 (*param->srv->logfunc)(param, "flushing buffer to client"); #endif res = socksendto(param->clisock, ¶m->sinc, param->srvbuf + param->srvoffset, param->srvinbuf - param->srvoffset, conf.timeouts[STRING_S] * 1000); if(res > 0){ param->srvoffset += res; -#ifndef NOPSTDINT param->statssrv64 += res; -#else - param->statssrv += res; -#endif if(param->srvoffset == param->srvinbuf) param->srvoffset = param->srvinbuf = 0; } else break; } -#ifndef NOPSTDINT while(!param->waitserver64 && param->cliinbuf > param->clioffset && param->remsock != INVALID_SOCKET){ -#else - while(!param->waitserver && param->cliinbuf > param->clioffset && param->remsock != INVALID_SOCKET){ -#endif #if DEBUGLEVEL > 2 (*param->srv->logfunc)(param, "flushing buffer to server"); #endif res = socksendto(param->remsock, ¶m->sins, param->clibuf + param->clioffset, param->cliinbuf - param->clioffset, conf.timeouts[STRING_S] * 1000); if(res > 0){ param->clioffset += res; -#ifndef NOPSTDINT param->statscli64 += res; -#else - param->statscli += res; -#endif if(param->cliinbuf == param->clioffset) param->cliinbuf = param->clioffset = 0; } else break; diff --git a/src/socks.c b/src/socks.c index e53250b..5bdba1d 100644 --- a/src/socks.c +++ b/src/socks.c @@ -339,11 +339,7 @@ fflush(stderr); param->res = 467; break; } -#ifndef NOPSTDINT param->statscli64+=(len - i); -#else - param->statscli+=(len - i); -#endif param->nwrites++; #if SOCKSTRACE > 1 fprintf(stderr, "UDP packet relayed from client to %s:%hu size %d, header %d\n", @@ -370,11 +366,7 @@ fflush(stderr); param->res = 468; break; } -#ifndef NOPSTDINT param->statssrv64+=len; -#else - param->statssrv+=len; -#endif param->nreads++; memcpy(buf+4, &tsin.sin_addr.s_addr, 4); memcpy(buf+8, &tsin.sin_port, 2); diff --git a/src/structures.h b/src/structures.h index a6e964f..40f6268 100644 --- a/src/structures.h +++ b/src/structures.h @@ -8,6 +8,9 @@ #include #ifndef NOPSTDINT #include "pstdint.h" +#else +typedef unsigned long uint64_t +#define PRINTF_INT64_MODIFIER "l" #endif #ifdef __cplusplus extern "C" { @@ -260,15 +263,8 @@ struct trafcount { struct ace *ace; unsigned number; ROTATION type; -#ifndef NOPSTDINT uint64_t traf64; uint64_t traflim64; -#else - unsigned long traf; - unsigned long trafgb; - unsigned long traflim; - unsigned long traflimgb; -#endif char * comment; int disabled; time_t cleared; @@ -385,13 +381,8 @@ struct clientparam { int res, status; -#ifndef NOPSTDINT uint64_t waitclient64, waitserver64; -#else - unsigned waitclient, - waitserver; -#endif int pwtype, threadid, weight, @@ -416,26 +407,15 @@ struct clientparam { clibufsize, srvbufsize, msec_start; -#ifndef NOPSTDINT uint64_t maxtrafin64, maxtrafout64; -#else - unsigned - maxtrafin, - maxtrafout; -#endif struct sockaddr_in sinc, sins, req; -#ifndef NOPSTDINT uint64_t statscli64, statssrv64; -#else - unsigned long statscli, - statssrv; -#endif unsigned long nreads, nwrites, diff --git a/src/webadmin.c b/src/webadmin.c index 516a04b..a4e6760 100644 --- a/src/webadmin.c +++ b/src/webadmin.c @@ -475,7 +475,6 @@ void * adminchild(struct clientparam* param) { ); } else { -#ifndef NOPSTDINT inbuf += sprintf(buf+inbuf, "%"PRINTF_INT64_MODIFIER"u" "MB%s" @@ -486,18 +485,6 @@ void * adminchild(struct clientparam* param) { cp->traf64, cp->cleared?ctime(&cp->cleared):"never" ); -#else - inbuf += sprintf(buf+inbuf, - "%.3f" - "MB%s" - "%.3f MB" - "%s", - (1024.0 * (float)cp->traflimgb) + (float)cp->traflim/1048576.0, - rotations[cp->type], - (1024.0 * (float)cp->trafgb) + (float)cp->traf/1048576.0, - cp->cleared?ctime(&cp->cleared):"never" - ); -#endif inbuf += sprintf(buf + inbuf, "%s" "%i"