1 #include <stdio.h> 2 #include <string.h> 3 #include "firedns.h" 4 main(int argc,char ** argv)5int main(int argc, char **argv) { 6 struct firedns_txtlist *iter; 7 char *spfrecord = NULL; 8 9 if (argc != 2) { 10 fprintf(stderr,"usage: %s <hostname>\n",argv[0]); 11 return 2; 12 } 13 14 iter = firedns_resolvetxtlist(argv[1]); 15 16 if (iter == NULL) 17 return 1; 18 19 while (iter != NULL) { 20 if (strncmp(iter->txt,"v=spf1 ",7) == 0) { 21 if (spfrecord != NULL) 22 return 1; 23 spfrecord = iter->txt; 24 } 25 iter = iter->next; 26 } 27 28 if (spfrecord == NULL) 29 return 1; 30 31 printf("%s\n",spfrecord); 32 33 return 0; 34 } 35