MCPcopy Create free account
hub / github.com/3proxy/3proxy / dumpcounters

Function dumpcounters

src/3proxy.c:193–233  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

191}
192
193void dumpcounters(struct trafcount *tlin, int counterd){
194
195 unsigned char tmpbuf[8192];
196 struct trafcount *tl;
197 if(counterd >= 0 && tlin) {
198
199 conf.time = time(0);
200 if(cheader.updated && conf.countertype && timechanged(cheader.updated, conf.time, conf.countertype)){
201 FILE * cfp;
202
203 cfp = fopen((char *)dologname(tmpbuf, (unsigned char *)conf.counterfile, NULL, conf.countertype, cheader.updated), "w");
204 if(cfp){
205 for(tl = tlin; cfp && tl; tl = tl->next){
206 if(tl->type >= conf.countertype)
207 fprintf(cfp, "%05d %020"PRINTF_INT64_MODIFIER"u%s%s\n", tl->number, tl->traf64, tl->comment?" #" : "", tl->comment? tl->comment : "");
208 }
209 fclose(cfp);
210 }
211 }
212
213
214 cheader.updated = conf.time;
215 lseek(counterd, 0, SEEK_SET);
216 write(counterd, &cheader, sizeof(struct counter_header));
217 for(tl=tlin; tl; tl = tl->next){
218 if(tl->number){
219 lseek(counterd,
220 sizeof(struct counter_header) + (tl->number - 1) * sizeof(struct counter_record),
221 SEEK_SET);
222 crecord.traf64 = tl->traf64;
223 crecord.cleared = tl->cleared;
224 crecord.updated = tl->updated;
225 write(counterd, &crecord, sizeof(struct counter_record));
226 }
227 if(tl->type!=NEVER && timechanged(tl->cleared, conf.time, tl->type)){
228 tl->cleared = conf.time;
229 tl->traf64 = 0;
230 }
231 }
232 }
233}
234
235void cyclestep(void){
236 struct tm *tm;

Callers 2

cyclestepFunction · 0.85
freeconfFunction · 0.85

Calls 2

timechangedFunction · 0.85
dolognameFunction · 0.85

Tested by

no test coverage detected