"Fossies" - the Fresh Open Source Software Archive

Member "libspf2-1.2.10/src/libspf2/spf_print.c" (28 Jan 2012, 2146 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_print.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 
   20 #ifdef STDC_HEADERS
   21 # include <stdio.h>        /* stdin / stdout */
   22 # include <stdlib.h>       /* malloc / free */
   23 # include <ctype.h>        /* isupper / tolower */
   24 #endif
   25 
   26 #ifdef HAVE_INTTYPES_H
   27 #include <inttypes.h>
   28 #endif
   29 
   30 #ifdef HAVE_STRING_H
   31 # include <string.h>       /* strstr / strdup */
   32 #else
   33 # ifdef HAVE_STRINGS_H
   34 #  include <strings.h>       /* strstr / strdup */
   35 # endif
   36 #endif
   37 
   38 
   39 #include "spf.h"
   40 #include "spf_internal.h"
   41 
   42 
   43 
   44 SPF_errcode_t
   45 SPF_record_print(SPF_record_t *spf_record)
   46 {
   47     char    *prt_buf = NULL;
   48     size_t   prt_len = 0;
   49     int      err;
   50 
   51     if (spf_record == NULL) {
   52         SPF_info("SPF header: <null record>");
   53         SPF_info("Unknown");
   54         return SPF_E_SUCCESS;
   55     }
   56 
   57     SPF_infof( "SPF header:  version: %d  mech %d/%u  mod %d/%u  len=%u",
   58         spf_record->version,
   59         (int)spf_record->num_mech, (unsigned int)spf_record->mech_len, 
   60         (int)spf_record->num_mod, (unsigned int)spf_record->mod_len,
   61         (unsigned int)(sizeof(SPF_record_t)
   62                 + spf_record->mech_len
   63                 + spf_record->mod_len));
   64 
   65     err = SPF_record_stringify(spf_record, &prt_buf, &prt_len);
   66     if ( err == SPF_E_RESULT_UNKNOWN )
   67     SPF_info( "Unknown" );
   68     else if ( err )
   69     SPF_infof( "SPF_record_stringify error: %s (%d)", SPF_strerror( err ), err );
   70     else
   71     SPF_infof( "SPF record:  %s", prt_buf );
   72 
   73     if ( prt_buf )
   74         free( prt_buf );
   75     return SPF_E_SUCCESS;
   76 }
   77 
   78 
   79 
   80 
   81 
   82 void SPF_print_sizeof(void)
   83 {
   84     // SPF_infof( "sizeof(SPF_rec_header_t)=%u", sizeof(SPF_rec_header_t));
   85     SPF_infof( "sizeof(SPF_mech_t)=%lu", (unsigned long)sizeof(SPF_mech_t));
   86     SPF_infof( "sizeof(SPF_data_t)=%lu", (unsigned long)sizeof(SPF_data_t));
   87     SPF_infof( "sizeof(SPF_mod_t)=%lu", (unsigned long)sizeof(SPF_mod_t));
   88 }