tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Extension to snprintb(3)
Folks,
Having recently purchased a couple of new processors, and trying to make
the output from cpuctl(8) look reasonable when decoding the various CPU
features, it's become apparent that the current snprintb(3) is somewhat
awkward to use. For large bit masks, one either has to manually "split"
the desired value across multiple calls (which leads to drastiscally
uneven line lengths and/or an unnecessarily large number of short lines)
or suffer from excessively long lines.
I propose a modified version of snprintb(3) which fills its output
buffer only with complete bit/field values. In addition to the current
return value, this modified version would take an additional u_quad_t
argument which would be set to the bit(s) that were NOT decoded in the
current output. This would allow one to repeatedly call the new
function, with a fixed-sized buffer, until all bits were decoded, and
would result in output lines that were reasonably equal in length.
Is this a reasonable idea? Any suggestion on what this new function
should be called?
int snprintbx(char *buf, size_t buflen, const char *fmt, u_quad_t *val);
-------------------------------------------------------------------------
| Paul Goyette | PGP DSS Key fingerprint: | E-mail addresses: |
| Customer Service | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com |
| Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette at juniper.net |
| Kernel Developer | | pgoyette at netbsd.org |
-------------------------------------------------------------------------
Home |
Main Index |
Thread Index |
Old Index