rdataslab.c revision 364a82f7c25b62967678027043425201a5e5171a
/*
* Copyright (C) 1999, 2000 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
/* $Id: rdataslab.c,v 1.11 2000/04/28 01:10:16 halley Exp $ */
#include <config.h>
#include <string.h>
#include <isc/assertions.h>
#include <dns/rdataclass.h>
#include <dns/rdatatype.h>
#include <dns/rdataset.h>
#include <dns/rdataslab.h>
{
unsigned char *rawbuf;
unsigned int buflen;
unsigned int nitems;
nitems = 0;
/*
* Run through the rdataset list once, counting up the size
* of all the rdata members within it. We do not store the
* class, type, etc, just the rdata, so our overhead is 2 bytes
* for the number of records, and 2 for each rdata length, and
* then the rdata itself.
*/
do {
nitems++;
} while (result == ISC_R_SUCCESS);
if (result != ISC_R_NOMORE)
return (result);
/*
* Allocate the memory, set up a buffer, start copying in
* data.
*/
return (ISC_R_NOMEMORY);
rawbuf += reservelen;
do {
} while (result == ISC_R_SUCCESS);
if (result != ISC_R_NOMORE) {
return (result);
}
return (ISC_R_SUCCESS);
}
unsigned int
unsigned char *current;
while (count > 0) {
count--;
}
}
{
/*
* Merge 'oslab' and 'nslab'.
*/
/*
* XXX Need parameter to allow "delete rdatasets in nslab" merge,
* or perhaps another merge routine for this purpose.
*/
/*
* Yes, this is inefficient!
*/
/*
* Figure out the length of the old slab's data.
*/
olength = 0;
}
/*
* Start figuring out the target length and count.
*/
/*
* Add in the length of rdata in the new slab that aren't in
* the old slab.
*/
do {
break;
}
/*
* This rdata isn't in the old slab.
*/
tcount++;
}
ncount--;
} while (ncount > 0);
if (!added_something && !force)
return (DNS_R_UNCHANGED);
/*
* Copy the reserved area from the new slab.
*/
return (ISC_R_NOMEMORY);
/*
* Write the new count.
*/
/*
* Copy the old slab.
*/
/*
* Copy the new parts of the new slab.
*/
do {
break;
}
/*
* This rdata isn't in the old slab.
*/
}
ncount--;
} while (ncount > 0);
return (ISC_R_SUCCESS);
}
unsigned char **tslabp)
{
/*
* Subtract 'sslab' from 'mslab'.
*/
/*
* Yes, this is inefficient!
*/
/*
* Start figuring out the target length and count.
*/
tcount = 0;
/*
* Add in the length of rdata in the mslab that aren't in
* the sslab.
*/
do {
break;
}
/*
* This rdata isn't in the sslab, and thus isn't
* being subtracted.
*/
tcount++;
} else
mcount--;
} while (mcount > 0);
/*
* Don't continue if the new rdataslab would be empty.
*/
if (tcount == 0)
return (DNS_R_NXRRSET);
/*
* If nothing is going to change, we can stop.
*/
if (!removed_something)
return (DNS_R_UNCHANGED);
/*
* Copy the reserved area from the mslab.
*/
return (ISC_R_NOMEMORY);
/*
* Write the new count.
*/
/*
* Copy the parts of mslab not in sslab.
*/
do {
break;
}
/*
* This rdata isn't in the sslab, and thus should be
* copied to the tslab.
*/
}
mcount--;
} while (mcount > 0);
return (ISC_R_SUCCESS);
}