tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Extension to snprintb(3)



On Mon, 4 May 2009, Christos Zoulas wrote:

In article <Pine.NEB.4.64.0905041512450.11316%quicky.whooppee.com@localhost>,
Paul Goyette  <paul%whooppee.com@localhost> wrote:
On Mon, 4 May 2009, Christos Zoulas wrote:

I propose a modified version of snprintb(3) which fills its output
buffer only with complete bit/field values.

snip

Well,this turns out to be fairly easy for the "old format" control
strings in snprintb(3), but it doesn't work well with "new format"
strings with field specifications.  In particular, it's just about
impossible to "remember" that you've already processed the first field
from

    ctl = "\177\20b\0B0\0b\1B1\0F\2\1fld\0=\0ZERO\0=\1ONE\0b\4B4\0"

since it is entirely acceptable for the 2-bit field to have a value of
zero.

snip

Well, it is easy to do for the new format too. Instead of doing it in
multiple calls, pass the maximum length in the call, and have snprintb
insert newlines, or make it return an array of allocated buffers.

Ah, just what I needed - someone looking at the forest instead of the trees!


-------------------------------------------------------------------------
|   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