summaryrefslogblamecommitdiffstats
path: root/domain2name_test.c
blob: c88aa0a7749b574a786650b372c8d03d7f0c9648 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12











                                                             








                                                                                                  



                                                                       
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "domain2name.c"
int main (int argc, char * const argv[]) {
	if (argc != 2) {
		fprintf(stderr, "%s domain\n", argv[0]);
		return 1;
	}
	int r, s = domain2name_len(argv[1], strlen(argv[1]));
	char * b = alloca(s);
	r = domain2name(b, argv[1], strlen(argv[1]));
	fprintf(stderr, "strlen %d name2domain_len %d\n", strlen(argv[1]), name2domain_len(b, b));
	int l = name2domain_len(b, b);
	if (l < 0) {
		fprintf(stderr, "name2domain_len error: %d\n", l);
	} else {
		char * d = alloca(l);
		name2domain(d, b, b);
		fprintf(stderr, "name2domain: %s\n", d);
	}
	printf("%4dB %4dB (-:\n", s, r); /* xxd has 16 bytes per row */
	printf("%s", b);
	fflush(stdout);
}