summaryrefslogtreecommitdiff
path: root/dnsstub/dns_domain.c
diff options
context:
space:
mode:
authorJannis Hoffmann <jannis@fehcom.de>2024-07-09 13:58:20 +0200
committerJannis Hoffmann <jannis@fehcom.de>2024-07-09 13:58:20 +0200
commit249866e3d1e11dc72eaa1305f4bb479ded92ef38 (patch)
tree7118c5f58e29fe61c100e4d067bb90ba8d52589e /dnsstub/dns_domain.c
parent96cf8dffe4f7b0b910f790066ae622dc429eb522 (diff)
reorganized file structure
Moved c files into src/. Corrected VERSION file. Removed BUILD and FILES.
Diffstat (limited to 'dnsstub/dns_domain.c')
-rw-r--r--dnsstub/dns_domain.c80
1 files changed, 0 insertions, 80 deletions
diff --git a/dnsstub/dns_domain.c b/dnsstub/dns_domain.c
deleted file mode 100644
index 654a827..0000000
--- a/dnsstub/dns_domain.c
+++ /dev/null
@@ -1,80 +0,0 @@
-#include "alloc.h"
-#include "case.h"
-#include "byte.h"
-#include "dnsresolv.h"
-
-/**
- @file dns_domain.c
- @author djb
- @source ucspi-tcp
- @brief domain qualification
-*/
-
-unsigned int dns_domain_length(const char *dn)
-{
- const char *x;
- unsigned char c;
-
- x = dn;
- while ((c = *x++))
- x += (unsigned int) c;
- return x - dn;
-}
-
-void dns_domain_free(char **out)
-{
- if (*out) {
- alloc_free(*out);
- *out = 0;
- }
-}
-
-int dns_domain_copy(char **out,const char *in)
-{
- unsigned int len;
- char *x;
-
- len = dns_domain_length(in);
- x = alloc(len);
- if (!x) return 0;
- byte_copy(x,len,in);
- if (*out) alloc_free(*out);
- *out = x;
- return 1;
-}
-
-int dns_domain_equal(const char *dn1,const char *dn2)
-{
- unsigned int len;
-
- len = dns_domain_length(dn1);
- if (len != dns_domain_length(dn2)) return 0;
-
- if (case_diffb((char *)dn1,len,(char *)dn2)) return 0; /* safe since 63 < 'A' */
- return 1;
-}
-
-int dns_domain_suffix(const char *big,const char *little)
-{
- unsigned char c;
-
- for (;;) {
- if (dns_domain_equal(big,little)) return 1;
- c = *big++;
- if (!c) return 0;
- big += c;
- }
-}
-
-unsigned int dns_domain_suffixpos(const char *big,const char *little)
-{
- const char *orig = big;
- unsigned char c;
-
- for (;;) {
- if (dns_domain_equal(big,little)) return big - orig;
- c = *big++;
- if (!c) return 0;
- big += c;
- }
-}