libspf2
1.2.10
|
00001 /* 00002 * This program is free software; you can redistribute it and/or modify 00003 * it under the terms of either: 00004 * 00005 * a) The GNU Lesser General Public License as published by the Free 00006 * Software Foundation; either version 2.1, or (at your option) any 00007 * later version, 00008 * 00009 * OR 00010 * 00011 * b) The two-clause BSD license. 00012 * 00013 * These licenses can be found with the distribution in the file LICENSES 00014 */ 00015 00016 #include "spf_sys_config.h" 00017 00018 00019 #ifdef STDC_HEADERS 00020 # include <stdio.h> /* stdin / stdout */ 00021 # include <stdlib.h> /* malloc / free */ 00022 #endif 00023 00024 #ifdef HAVE_STRING_H 00025 # include <string.h> /* strstr / strdup */ 00026 #else 00027 # ifdef HAVE_STRINGS_H 00028 # include <strings.h> /* strstr / strdup */ 00029 # endif 00030 #endif 00031 00032 00033 00034 #include "spf.h" 00035 #include "spf_dns.h" 00036 #include "spf_internal.h" 00037 #include "spf_dns_internal.h" 00038 #include "spf_dns_null.h" 00039 00040 00041 static SPF_dns_rr_t * 00042 SPF_dns_null_lookup(SPF_dns_server_t *spf_dns_server, 00043 const char *domain, ns_type rr_type, int should_cache) 00044 { 00045 if (spf_dns_server->layer_below) 00046 return SPF_dns_lookup(spf_dns_server->layer_below, 00047 domain, rr_type, should_cache); 00048 return SPF_dns_rr_new_nxdomain(spf_dns_server, domain); 00049 } 00050 00051 static void 00052 SPF_dns_null_free( SPF_dns_server_t *spf_dns_server ) 00053 { 00054 SPF_ASSERT_NOTNULL(spf_dns_server); 00055 free(spf_dns_server); 00056 } 00057 00058 SPF_dns_server_t * 00059 SPF_dns_null_new(SPF_dns_server_t *spf_dns_server_below, 00060 const char *name, int debug) 00061 { 00062 SPF_dns_server_t *spf_dns_server; 00063 00064 spf_dns_server = malloc(sizeof(SPF_dns_server_t)); 00065 if ( spf_dns_server == NULL ) 00066 return NULL; 00067 memset(spf_dns_server, 0, sizeof(SPF_dns_server_t)); 00068 00069 if (name == NULL) 00070 name = "null"; 00071 00072 spf_dns_server->destroy = SPF_dns_null_free; 00073 spf_dns_server->lookup = SPF_dns_null_lookup; 00074 spf_dns_server->get_spf = NULL; 00075 spf_dns_server->get_exp = NULL; 00076 spf_dns_server->add_cache = NULL; 00077 spf_dns_server->layer_below = spf_dns_server_below; 00078 spf_dns_server->name = name; 00079 spf_dns_server->debug = debug; 00080 00081 return spf_dns_server; 00082 }