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

Function dobuf2

src/common.c:358–602  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

356
357
358int dobuf2(struct clientparam * param, unsigned char * buf, const unsigned char *s, const unsigned char * doublec, struct tm* tm, char * format){
359 int i, j;
360 int len;
361 time_t sec;
362 unsigned msec;
363
364 long timezone;
365 unsigned delay;
366
367
368
369#ifdef _WIN32
370 struct timeb tb;
371
372 ftime(&tb);
373 sec = (time_t)tb.time;
374 msec = (unsigned)tb.millitm;
375 timezone = tm->tm_isdst*60 - tb.timezone;
376
377#else
378 struct timeval tv;
379 struct timezone tz;
380 gettimeofday(&tv, &tz);
381
382 sec = (time_t)tv.tv_sec;
383 msec = tv.tv_usec / 1000;
384#ifdef _SOLARIS
385 timezone = -altzone / 60;
386#else
387 timezone = tm->tm_gmtoff / 60;
388#endif
389#endif
390
391 delay = param->time_start?((unsigned) ((sec - param->time_start))*1000 + msec) - param->msec_start : 0;
392 *buf = 0;
393 for(i=0, j=0; format[j] && i < 4040; j++){
394 if(format[j] == '%' && format[j+1]){
395 j++;
396 switch(format[j]){
397 case '%':
398 buf[i++] = '%';
399 break;
400 case 'y':
401 sprintf((char *)buf+i, "%.2d", tm->tm_year%100);
402 i+=2;
403 break;
404 case 'Y':
405 sprintf((char *)buf+i, "%.4d", tm->tm_year+1900);
406 i+=4;
407 break;
408 case 'm':
409 sprintf((char *)buf+i, "%.2d", tm->tm_mon+1);
410 i+=2;
411 break;
412 case 'o':
413 sprintf((char *)buf+i, "%s", months[tm->tm_mon]);
414 i+=3;
415 break;

Callers 2

dobufFunction · 0.85
dolognameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected