contrib/ldns/str2host.c
ldns_status
ldns_str2rdf_cert_alg(ldns_rdf **rd, const char *str)
{
	ldns_lookup_table *lt;
	ldns_status st;
	uint8_t idd[2];
	lt = ldns_lookup_by_name(ldns_cert_algorithms, str);
	st = LDNS_STATUS_OK;

	if (lt) {
		ldns_write_uint16(idd, (uint16_t) lt->id);
		*rd = ldns_rdf_new_frm_data(
			LDNS_RDF_TYPE_INT16, sizeof(uint16_t), idd);
		if (!*rd) {
			st = LDNS_STATUS_ERR;
		}
	} else {
		/* try as-is (a number) */
		st = ldns_str2rdf_int16(rd, str);
		if (st == LDNS_STATUS_OK &&
		    ldns_rdf2native_int16(*rd) == 0) {
			st = LDNS_STATUS_CERT_BAD_ALGORITHM;
		}
	}

	return st;
}
/* An certificate alg field can either be specified as a 8 bits number
 * or by its symbolic name. Handle both
 */
An certificate alg field can either be specified as a 8 bits number
or by its symbolic name. Handle both
An certificate alg field can either be specified as a 8 bits number or by its symbolic name . Handle both
ldns_status
ldns_str2rdf_cert_alg(ldns_rdf **rd, const char *str)
{
	ldns_lookup_table *lt;
	ldns_status st;
	uint8_t idd[2];
	lt = ldns_lookup_by_name(ldns_cert_algorithms, str);
	st = LDNS_STATUS_OK;
	if (lt) {
		ldns_write_uint16(idd, (uint16_t) lt->id);
		*rd = ldns_rdf_new_frm_data(
			LDNS_RDF_TYPE_INT16, sizeof(uint16_t), idd);
		if (!*rd) {
			st = LDNS_STATUS_ERR;
		}
	} else {
		st = ldns_str2rdf_int16(rd, str);
		if (st == LDNS_STATUS_OK &&
		    ldns_rdf2native_int16(*rd) == 0) {
			st = LDNS_STATUS_CERT_BAD_ALGORITHM;
		}
	}
	return st;
}
ldns_status ldns_str2rdf_cert_alg ( ldns_rdf * * rd , const char * str ) { ldns_lookup_table * lt ; ldns_status st ; uint8_t idd [ 2 ] ; lt = ldns_lookup_by_name ( ldns_cert_algorithms , str ) ; st = LDNS_STATUS_OK ; if ( lt ) { ldns_write_uint16 ( idd , ( uint16_t ) lt -> id ) ; * rd = ldns_rdf_new_frm_data ( LDNS_RDF_TYPE_INT16 , sizeof ( uint16_t ) , idd ) ; if ( ! * rd ) { st = LDNS_STATUS_ERR ; } } else { st = ldns_str2rdf_int16 ( rd , str ) ; if ( st == LDNS_STATUS_OK && ldns_rdf2native_int16 ( * rd ) == 0 ) { st = LDNS_STATUS_CERT_BAD_ALGORITHM ; } } return st ; }
An certificate alg field can either be specified as a 8 bits number
 or by its symbolic name.
An certificate alg field can either be specified as a 8 bits number or by its symbolic name .
/* try as-is (a number) */