"Fossies" - the Fresh Open Source Software Archive

Member "libspf2-1.2.10/src/libspf2/spf_dns_null.c" (28 Jan 2012, 2059 Bytes) of package /linux/privat/libspf2-1.2.10.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "spf_dns_null.c" see the Fossies "Dox" file reference documentation.

    1 /* 
    2  * This program is free software; you can redistribute it and/or modify
    3  * it under the terms of either:
    4  * 
    5  *   a) The GNU Lesser General Public License as published by the Free
    6  *      Software Foundation; either version 2.1, or (at your option) any
    7  *      later version, 
    8  * 
    9  *   OR
   10  * 
   11  *   b) The two-clause BSD license.
   12  *
   13  * These licenses can be found with the distribution in the file LICENSES
   14  */
   15 
   16 #include "spf_sys_config.h"
   17 
   18 
   19 #ifdef STDC_HEADERS
   20 # include <stdio.h>        /* stdin / stdout */
   21 # include <stdlib.h>       /* malloc / free */
   22 #endif
   23 
   24 #ifdef HAVE_STRING_H
   25 # include <string.h>       /* strstr / strdup */
   26 #else
   27 # ifdef HAVE_STRINGS_H
   28 #  include <strings.h>       /* strstr / strdup */
   29 # endif
   30 #endif
   31 
   32 
   33 
   34 #include "spf.h"
   35 #include "spf_dns.h"
   36 #include "spf_internal.h"
   37 #include "spf_dns_internal.h"
   38 #include "spf_dns_null.h"
   39 
   40 
   41 static SPF_dns_rr_t *
   42 SPF_dns_null_lookup(SPF_dns_server_t *spf_dns_server,
   43                 const char *domain, ns_type rr_type, int should_cache)
   44 {
   45     if (spf_dns_server->layer_below)
   46         return SPF_dns_lookup(spf_dns_server->layer_below,
   47                         domain, rr_type, should_cache);
   48     return SPF_dns_rr_new_nxdomain(spf_dns_server, domain);
   49 }
   50 
   51 static void
   52 SPF_dns_null_free( SPF_dns_server_t *spf_dns_server )
   53 {
   54     SPF_ASSERT_NOTNULL(spf_dns_server);
   55     free(spf_dns_server);
   56 }
   57 
   58 SPF_dns_server_t *
   59 SPF_dns_null_new(SPF_dns_server_t *spf_dns_server_below,
   60                 const char *name, int debug)
   61 {
   62     SPF_dns_server_t        *spf_dns_server;
   63 
   64     spf_dns_server = malloc(sizeof(SPF_dns_server_t));
   65     if ( spf_dns_server == NULL )
   66         return NULL;
   67     memset(spf_dns_server, 0, sizeof(SPF_dns_server_t));
   68 
   69     if (name ==  NULL)
   70         name = "null";
   71 
   72     spf_dns_server->destroy      = SPF_dns_null_free;
   73     spf_dns_server->lookup       = SPF_dns_null_lookup;
   74     spf_dns_server->get_spf      = NULL;
   75     spf_dns_server->get_exp      = NULL;
   76     spf_dns_server->add_cache    = NULL;
   77     spf_dns_server->layer_below  = spf_dns_server_below;
   78     spf_dns_server->name         = name;
   79     spf_dns_server->debug        = debug;
   80 
   81     return spf_dns_server;
   82 }