Use %b qualifier just like printf(9)

This commit is contained in:
dcp1990 2005-06-12 17:03:35 +00:00
parent ca506e92e9
commit a55f52c205

View File

@ -59,6 +59,10 @@ int lprintf(enum ltype logtype, const char* fmt, ...)
char* str;
void* voi;
int maxsize;
int tmp;
const char *p;
long num;
unsigned n;
time_t now;
char tmt[128];
now = time(NULL);
@ -98,6 +102,24 @@ int lprintf(enum ltype logtype, const char* fmt, ...)
uns = va_arg(ap, unsigned);
cnt += fprintf(logf, ofmt, uns);
break;
case 'b':
num = (unsigned int)va_arg(ap, int);
p = va_arg(ap, char *);
if(num == 0) break;
for(tmp = 0; *p;) {
n = (int)p++;
if(num & (1 << (n - 1))) {
fputc(tmp ? ',' : '<', logf);
for(;(n = *p) > ' '; ++p)
fputc(n, logf);
tmp = 1;
} else
for(;*p > ' '; ++p)
continue;
}
if(tmp)
fputc('>', logf);
break;
case 'c':
cha = (char) va_arg(ap, int);
cnt += fprintf(logf, ofmt, cha);