32 #ifdef HAVE_SYS_TYPES_H
33 #include <sys/types.h>
36 #ifdef HAVE_INTTYPES_H
43 # ifdef HAVE_STRINGS_H
48 #ifdef HAVE_SYS_SOCKET_H
49 # include <sys/socket.h>
51 #ifdef HAVE_NETINET_IN_H
52 # include <netinet/in.h>
54 #ifdef HAVE_ARPA_INET_H
55 # include <arpa/inet.h>
58 #ifdef HAVE_ARPA_NAMESER_H
59 # include <arpa/nameser.h>
89 "spf_example [options]\n"
91 "Valid data options are:\n"
92 " -i <IP address> The IP address that is sending email\n"
93 " -s <email address> The email address used as the\n"
94 " envelope-from. If no username (local\n"
95 " part) is given, 'postmaster' will be\n"
97 " -r <email address> [optional] The email address used as\n"
98 " the envelope-to email address, for\n"
99 " secondary-MX checking.\n"
100 " -h <domain name> The domain name given on the SMTP HELO\n"
101 " command. This is only needed if the\n"
102 " -sender option is not given.\n"
103 " -d [debug level] debug level.\n"
114 int main(
int argc,
char *argv[] )
121 char *opt_sender =
NULL;
122 char *opt_helo =
NULL;
123 char *opt_rcpt_to =
NULL;
131 SPF_server_t *spf_server =
NULL;
132 SPF_request_t *spf_request =
NULL;
133 SPF_response_t *spf_response =
NULL;
134 SPF_response_t *spf_response_2mx =
NULL;
143 c = getopt(argc, argv,
"i:s:h:r:d::" );
163 opt_rcpt_to = optarg;
177 opt_debug = atoi( optarg );
181 fprintf( stderr,
"Error: getopt returned character code 0%o ??\n", c);
187 || (opt_helo ==
NULL && opt_sender ==
NULL))
211 if (spf_server ==
NULL) {
212 fprintf( stderr,
"SPF_create_config failed.\n" );
251 printf(
"Invalid IP address.\n" );
268 printf(
"Invalid HELO domain.\n" );
279 printf(
"Invalid envelope from address.\n" );
325 if ( opt_debug > 0 ) {
326 printf (
"result = %s (%d)\n",
329 printf (
"err = %s (%d)\n",
334 printf (
"%s_msg = (%d) %s\n",
341 #define VALID_STR(x) (x ? x : "")
343 printf(
"%s\n%s\n%s\n%s\n",
359 if (spf_response_2mx)