wire_test.c revision 1448a52296946ff085db120604c5a87d1a5c458a
/*
* Copyright (C) 1999-2001 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: wire_test.c,v 1.57 2001/05/09 00:16:48 bwelling Exp $ */
#include <config.h>
#include <stdlib.h>
#include "printmsg.h"
static inline void
if (result != ISC_R_SUCCESS) {
exit(1);
}
}
static int
fromhex(char c) {
if (c >= '0' && c <= '9')
return (c - '0');
else if (c >= 'a' && c <= 'f')
return (c - 'a' + 10);
else if (c >= 'A' && c <= 'F')
return (c - 'A' + 10);
printf("bad input format: %02x\n", c);
exit(3);
/* NOTREACHED */
}
int
unsigned char *bp;
int n;
FILE *f;
unsigned char b[64 * 1024];
char s[4000];
if (argc > 1) {
if (f == NULL) {
printf("fopen failed\n");
exit(1);
}
} else
f = stdin;
bp = b;
rp = s;
wp = s;
len = 0;
while (*rp != '\0') {
if (*rp == '#')
break;
len++;
}
rp++;
}
if (len == 0)
break;
if (len % 2 != 0) {
exit(1);
}
if (len > (sizeof b) * 2) {
printf("input too long\n");
exit(2);
}
rp = s;
for (i = 0; i < len; i += 2) {
n *= 16;
*bp++ = n;
}
}
if (need_close)
fclose(f);
isc_buffer_init(&source, b, sizeof(b));
/* CHECKRESULT(result, "dns_message_parse failed");*/
/*
* XXXMLG
* Changing this here is a hack, and should not be done in reasonable
* application code, ever.
*/
memset(b, 0, sizeof(b));
for (i = 0 ; i < DNS_SECTION_MAX ; i++)
printf("Message rendered.\n");
return (0);
}