Skip to content
Snippets Groups Projects
Commit 909720a0 authored by Jan Kadlec's avatar Jan Kadlec
Browse files

Initial node API implementation.

parent d42ee63f
Branches
Tags
No related merge requests found
/*
* File node.c
* Date 11.11.2010 15:38
* Author: Jan Kadlec jan.kadlec@nic.cz
* Project: CuteDNS
* Description:
*/
#include <malloc.h>
#include "common.h"
#include "node.h"
#include "rrset.h"
int compare_rrset_types( void *rrset_1, void *rrset_2 )
{
dnslib_rrset_t *rrs1 = (dnslib_rrset_t *) rrset_1;
dnslib_rrset_t *rrs2 = (dnslib_rrset_t *) rrset_2;
return (rrs1->type == rrs2->type ? 0 :
rrs1->type < rrs2->type ? -1 : 1);
}
dnslib_node_t *dnslib_node_new( dnslib_dname_t *owner, dnslib_node_t *parent )
{
dnslib_node_t *ret = malloc(sizeof(dnslib_node_t));
if (ret == NULL) {
// ERR_ALLOC_MEMORY;
return NULL;
}
ret->owner = owner;
ret->parent = parent;
ret->rrsets = skip_create_list(compare_rrset_types);
return ret;
}
int dnslib_node_add_rrset( dnslib_node_t *node, dnslib_rrset_t *rrset )
{
if ((skip_insert(node->rrsets, &rrset->type, &rrset, NULL)) != 0) {
return -2;
}
return 0;
}
const dnslib_rrset_t *dnslib_node_get_rrset( const dnslib_node_t *node,
uint16_t type )
{
return (dnslib_rrset_t*)skip_find(node->rrsets, &type);
}
const dnslib_node_t *dnslib_node_get_parent( const dnslib_node_t *node )
{
return node->parent;
}
/* end of file node.c */
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment