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 00020 #ifdef STDC_HEADERS 00021 # include <stdio.h> /* stdin / stdout */ 00022 # include <stdlib.h> /* malloc / free */ 00023 # include <ctype.h> /* isupper / tolower */ 00024 #endif 00025 00026 #ifdef HAVE_INTTYPES_H 00027 #include <inttypes.h> 00028 #endif 00029 00030 #ifdef HAVE_STRING_H 00031 # include <string.h> /* strstr / strdup */ 00032 #else 00033 # ifdef HAVE_STRINGS_H 00034 # include <strings.h> /* strstr / strdup */ 00035 # endif 00036 #endif 00037 00038 00039 #include "spf.h" 00040 #include "spf_internal.h" 00041 00042 00043 00044 SPF_errcode_t 00045 SPF_record_print(SPF_record_t *spf_record) 00046 { 00047 char *prt_buf = NULL; 00048 size_t prt_len = 0; 00049 int err; 00050 00051 if (spf_record == NULL) { 00052 SPF_info("SPF header: <null record>"); 00053 SPF_info("Unknown"); 00054 return SPF_E_SUCCESS; 00055 } 00056 00057 SPF_infof( "SPF header: version: %d mech %d/%u mod %d/%u len=%u", 00058 spf_record->version, 00059 (int)spf_record->num_mech, (unsigned int)spf_record->mech_len, 00060 (int)spf_record->num_mod, (unsigned int)spf_record->mod_len, 00061 (unsigned int)(sizeof(SPF_record_t) 00062 + spf_record->mech_len 00063 + spf_record->mod_len)); 00064 00065 err = SPF_record_stringify(spf_record, &prt_buf, &prt_len); 00066 if ( err == SPF_E_RESULT_UNKNOWN ) 00067 SPF_info( "Unknown" ); 00068 else if ( err ) 00069 SPF_infof( "SPF_record_stringify error: %s (%d)", SPF_strerror( err ), err ); 00070 else 00071 SPF_infof( "SPF record: %s", prt_buf ); 00072 00073 if ( prt_buf ) 00074 free( prt_buf ); 00075 return SPF_E_SUCCESS; 00076 } 00077 00078 00079 00080 00081 00082 void SPF_print_sizeof(void) 00083 { 00084 // SPF_infof( "sizeof(SPF_rec_header_t)=%u", sizeof(SPF_rec_header_t)); 00085 SPF_infof( "sizeof(SPF_mech_t)=%lu", (unsigned long)sizeof(SPF_mech_t)); 00086 SPF_infof( "sizeof(SPF_data_t)=%lu", (unsigned long)sizeof(SPF_data_t)); 00087 SPF_infof( "sizeof(SPF_mod_t)=%lu", (unsigned long)sizeof(SPF_mod_t)); 00088 }