sprint_realloc_hinted_integer(u_char ** buf, size_t * buf_len,
                              size_t * out_len, int allow_realloc,
                              long val, const char decimaltype,
                              const char *hint, const char *units)
{
    char            fmt[10] = "%l@", tmp[256];
    int             shift = 0, len, negative = 0;

    if (hint[0] == 'd') {
        /*
         * We might *actually* want a 'u' here.  
         */
        if (hint[1] == '-')
            shift = atoi(hint + 2);
        fmt[2] = decimaltype;
        if (val < 0) {
            negative = 1;
            val = -val;
        }
    } else {
        /*
         * DISPLAY-HINT character is 'b', 'o', or 'x'.  
         */
        fmt[2] = hint[0];
    }

    if (hint[0] == 'b') {
	unsigned long int bit = 0x80000000LU;
	char *bp = tmp;
	while (bit) {
	    *bp++ = val & bit ? '1' : '0';
	    bit >>= 1;
	}
	*bp = 0;
    }
    else
	sprintf(tmp, fmt, val);

    if (shift != 0) {
        len = strlen(tmp);
        if (shift <= len) {
            tmp[len + 1] = 0;
            while (shift--) {
                tmp[len] = tmp[len - 1];
                len--;
            }
            tmp[len] = '.';
        } else {
            tmp[shift + 1] = 0;
            while (shift) {
                if (len-- > 0) {
                    tmp[shift] = tmp[len];
                } else {
                    tmp[shift] = '0';
                }
                shift--;
            }
            tmp[0] = '.';
        }
    }
    if (negative) {
        len = strlen(tmp)+1;
        while (len) {
            tmp[len] = tmp[len-1];
            len--;
        }
        tmp[0] = '-';
    }
    return snmp_strcat(buf, buf_len, out_len, allow_realloc, (u_char *)tmp);
}
sprint_realloc_hinted_integer(u_char ** buf, size_t * buf_len,
                              size_t * out_len, int allow_realloc,
                              long val, const char decimaltype,
                              const char *hint, const char *units)
{
    char            fmt[10] = "%l@", tmp[256];
    int             shift = 0, len, negative = 0;

    if (hint[0] == 'd') {
         
        if (hint[1] == '-')
            shift = atoi(hint + 2);
        fmt[2] = decimaltype;
        if (val < 0) {
            negative = 1;
            val = -val;
        }
    } else {
         
        fmt[2] = hint[0];
    }

    if (hint[0] == 'b') {
	unsigned long int bit = 0x80000000LU;
	char *bp = tmp;
	while (bit) {
	    *bp++ = val & bit ? '1' : '0';
	    bit >>= 1;
	}
	*bp = 0;
    }
    else
	sprintf(tmp, fmt, val);

    if (shift != 0) {
        len = strlen(tmp);
        if (shift <= len) {
            tmp[len + 1] = 0;
            while (shift--) {
                tmp[len] = tmp[len - 1];
                len--;
            }
            tmp[len] = '.';
        } else {
            tmp[shift + 1] = 0;
            while (shift) {
                if (len-- > 0) {
                    tmp[shift] = tmp[len];
                } else {
                    tmp[shift] = '0';
                }
                shift--;
            }
            tmp[0] = '.';
        }
    }
    if (negative) {
        len = strlen(tmp)+1;
        while (len) {
            tmp[len] = tmp[len-1];
            len--;
        }
        tmp[0] = '-';
    }
    return snmp_strcat(buf, buf_len, out_len, allow_realloc, (u_char *)tmp);
}