libspf2
1.2.11
src
libspf2
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
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
}
SPF_strerror
const char * SPF_strerror(SPF_errcode_t spf_err)
Definition:
spf_strerror.c:33
SPF_record_print
SPF_errcode_t SPF_record_print(SPF_record_t *spf_record)
Definition:
spf_print.c:45
SPF_errcode_t
SPF_errcode_t
Definition:
spf_response.h:119
SPF_infof
#define SPF_infof
Definition:
spf_log.h:79
SPF_mech_t
Definition:
spf_record.h:175
spf.h
SPF_print_sizeof
void SPF_print_sizeof(void)
Definition:
spf_print.c:82
SPF_E_SUCCESS
@ SPF_E_SUCCESS
Definition:
spf_response.h:120
SPF_record_stringify
SPF_errcode_t SPF_record_stringify(SPF_record_t *spf_record, char **bufp, size_t *buflenp)
Definition:
spf_id2str.c:245
SPF_data_t
Definition:
spf_record.h:142
spf_internal.h
SPF_mod_t
Definition:
spf_record.h:188
SPF_info
#define SPF_info(errmsg)
Definition:
spf_log.h:50
NULL
#define NULL
Definition:
spf_internal.h:28
spf_sys_config.h
SPF_E_RESULT_UNKNOWN
@ SPF_E_RESULT_UNKNOWN
Definition:
spf_response.h:142
Generated by
1.8.20