add alternate format
This commit is contained in:
parent
a4bbf47b33
commit
821fff983b
@ -28,8 +28,10 @@ int
|
|||||||
eipfmt(Fmt *f)
|
eipfmt(Fmt *f)
|
||||||
{
|
{
|
||||||
char buf[5*8];
|
char buf[5*8];
|
||||||
static char *efmt = "%.2lux%.2lux%.2lux%.2lux%.2lux%.2lux";
|
static char *efmt = "%.2ux%.2ux%.2ux%.2ux%.2ux%.2ux";
|
||||||
|
static char *altefmt = "%.2ux:%.2ux:%.2ux:%.2ux:%.2ux:%.2ux";
|
||||||
static char *ifmt = "%d.%d.%d.%d";
|
static char *ifmt = "%d.%d.%d.%d";
|
||||||
|
char *fmt;
|
||||||
uchar *p, ip[16];
|
uchar *p, ip[16];
|
||||||
ulong *lp;
|
ulong *lp;
|
||||||
ushort s;
|
ushort s;
|
||||||
@ -54,6 +56,9 @@ eipfmt(Fmt *f)
|
|||||||
switch(f->r) {
|
switch(f->r) {
|
||||||
case 'E': /* Ethernet address */
|
case 'E': /* Ethernet address */
|
||||||
p = va_arg(f->args, uchar*);
|
p = va_arg(f->args, uchar*);
|
||||||
|
fmt = efmt;
|
||||||
|
if(f->flags&FmtSharp)
|
||||||
|
fmt = altefmt;
|
||||||
snprint(buf, sizeof buf, efmt, p[0], p[1], p[2], p[3], p[4], p[5]);
|
snprint(buf, sizeof buf, efmt, p[0], p[1], p[2], p[3], p[4], p[5]);
|
||||||
return fmtstrcpy(f, buf);
|
return fmtstrcpy(f, buf);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user