skeletons/OBJECT_IDENTIFIER.c
/*
 * Save the single value as an object identifier arc.
 */
Save the single value as an object identifier arc.
Save the single value as an object identifier arc .
ssize_t
OBJECT_IDENTIFIER_set_single_arc(uint8_t *arcbuf, size_t arcbuf_len,
                                 asn_oid_arc_t value) {
    uint8_t scratch[((sizeof(value) * CHAR_BIT + 6) / 7)];
    uint8_t *scratch_end = &scratch[sizeof(scratch)-1];
    uint8_t *b;
    size_t result_len;
    uint8_t mask;
    for(b = scratch_end, mask = 0; ; mask = 0x80, b--) {
        *b = mask | (value & 0x7f);
        value >>= 7;
        if(!value) {
            break;
        }
    }
    result_len = (scratch_end - b) + 1;
    if(result_len > arcbuf_len) {
        return -1;
    }
    memcpy(arcbuf, b, result_len);
	return result_len;
}
ssize_t OBJECT_IDENTIFIER_set_single_arc ( uint8_t * arcbuf , size_t arcbuf_len , asn_oid_arc_t value ) { uint8_t scratch [ ( ( sizeof ( value ) * CHAR_BIT + 6 ) / 7 ) ] ; uint8_t * scratch_end = & scratch [ sizeof ( scratch ) - 1 ] ; uint8_t * b ; size_t result_len ; uint8_t mask ; for ( b = scratch_end , mask = 0 ; ; mask = 0x80 , b -- ) { * b = mask | ( value & 0x7f ) ; value >>= 7 ; if ( ! value ) { break ; } } result_len = ( scratch_end - b ) + 1 ; if ( result_len > arcbuf_len ) { return -1 ; } memcpy ( arcbuf , b , result_len ) ; return result_len ; }
Save the single value as an object identifier arc.
Save the single value as an object identifier arc .
/*
	 * The following conditions must hold:
	 * assert(arcbuf);
	 */