bin/tests/system/dlzexternal/driver.c
/*
 * Add a record to a list
 */
Add a record to a list
Add a record to a list
static isc_result_t
add_name(struct dlz_example_data *state, struct record *list,
	 const char *name, const char *type, dns_ttl_t ttl, const char *data)
{
	int i;
	isc_boolean_t single = single_valued(type);
	int first_empty = -1;
	for (i = 0; i < MAX_RECORDS; i++) {
		if (first_empty == -1 && strlen(list[i].name) == 0U) {
			first_empty = i;
		}
		if (strcasecmp(list[i].name, name) != 0)
			continue;
		if (strcasecmp(list[i].type, type) != 0)
			continue;
		if (!single && strcasecmp(list[i].data, data) != 0)
			continue;
		break;
	}
	if (i == MAX_RECORDS && first_empty != -1) {
		i = first_empty;
	}
	if (i == MAX_RECORDS) {
		state->log(ISC_LOG_ERROR, "dlz_example: out of record space");
		return (ISC_R_FAILURE);
	}
	strcpy(list[i].name, name);
	strcpy(list[i].type, type);
	strcpy(list[i].data, data);
	list[i].ttl = ttl;
	return (ISC_R_SUCCESS);
}
static isc_result_t add_name ( struct dlz_example_data * state , struct record * list , const char * name , const char * type , dns_ttl_t ttl , const char * data ) { int i ; isc_boolean_t single = single_valued ( type ) ; int first_empty = -1 ; for ( i = 0 ; i < MAX_RECORDS ; i ++ ) { if ( first_empty == -1 && strlen ( list [ i ] . name ) == 0U ) { first_empty = i ; } if ( strcasecmp ( list [ i ] . name , name ) != 0 ) continue ; if ( strcasecmp ( list [ i ] . type , type ) != 0 ) continue ; if ( ! single && strcasecmp ( list [ i ] . data , data ) != 0 ) continue ; break ; } if ( i == MAX_RECORDS && first_empty != -1 ) { i = first_empty ; } if ( i == MAX_RECORDS ) { state -> log ( ISC_LOG_ERROR , " " ) ; return ( ISC_R_FAILURE ) ; } strcpy ( list [ i ] . name , name ) ; strcpy ( list [ i ] . type , type ) ; strcpy ( list [ i ] . data , data ) ; list [ i ] . ttl = ttl ; return ( ISC_R_SUCCESS ) ; }
Add a record to a list
Add a record to a list