lib/dns/master.c
/*%
 * Convert value into a nibble sequence from least significant to most
 * significant nibble.  Zero fill upper most significant nibbles if
 * required to make the width.
 *
 * Returns the number of characters that should have been written without
 * counting the terminating NUL.
 */
%
Convert value into a nibble sequence from least significant to most
significant nibble.  Zero fill upper most significant nibbles if
required to make the width.

Returns the number of characters that should have been written without
counting the terminating NUL.
% Convert value into a nibble sequence from least significant to most significant nibble . Zero fill upper most significant nibbles if required to make the width . Returns the number of characters that should have been written without counting the terminating NUL .
static unsigned int
nibbles(char *numbuf, size_t length, unsigned int width, char mode, int value) {
	unsigned int count = 0;
	if (length > 0U) {
		*numbuf = '\0';
		length--;
	}
	do {
		char val = hex[(value & 0x0f) + ((mode == 'n') ? 0 : 16)];
		value >>= 4;
		if (length > 0U) {
			*numbuf++ = val;
			*numbuf = '\0';
			length--;
		}
		if (width > 0)
			width--;
		count++;
		if (width > 0 || value != 0) {
			if (length > 0U) {
				*numbuf++ = '.';
				*numbuf = '\0';
				length--;
			}
			if (width > 0)
				width--;
			count++;
		}
	} while (value != 0 || width > 0);
	return (count);
}
static unsigned int nibbles ( char * numbuf , size_t length , unsigned int width , char mode , int value ) { unsigned int count = 0 ; if ( length > 0U ) { * numbuf = ' \0 ' ; length -- ; } do { char val = hex [ ( value & 0x0f ) + ( ( mode == ' ' ) ? 0 : 16 ) ] ; value >>= 4 ; if ( length > 0U ) { * numbuf ++ = val ; * numbuf = ' \0 ' ; length -- ; } if ( width > 0 ) width -- ; count ++ ; if ( width > 0 || value != 0 ) { if ( length > 0U ) { * numbuf ++ = ' ' ; * numbuf = ' \0 ' ; length -- ; } if ( width > 0 ) width -- ; count ++ ; } } while ( value != 0 || width > 0 ) ; return ( count ) ; }
%
 Convert value into a nibble sequence from least significant to most
 significant nibble.
% Convert value into a nibble sequence from least significant to most significant nibble .
/*
	 * This reserve space for the NUL string terminator.
	 */ /*
		 * If width is non zero then we need to add a label seperator.
		 * If value is non zero then we need to add another label and
		 * that requires a label seperator.
		 */