libspf2 1.2.11
spf_print.c
Go to the documentation of this file.
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
45SPF_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
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}
SPF_errcode_t
@ SPF_E_SUCCESS
@ SPF_E_RESULT_UNKNOWN
SPF_errcode_t SPF_record_stringify(SPF_record_t *spf_record, char **bufp, size_t *buflenp)
Definition spf_id2str.c:245
const char * SPF_strerror(SPF_errcode_t spf_err)
#define SPF_infof
Definition spf_log.h:79
#define SPF_info(errmsg)
Definition spf_log.h:50
#define NULL
SPF_errcode_t SPF_record_print(SPF_record_t *spf_record)
Definition spf_print.c:45
void SPF_print_sizeof(void)
Definition spf_print.c:82