*/
/********************************************************/
/* */
+/* Procedure to extrac keywork from line */
+/* */
+/********************************************************/
+static int getkeyword(char *keyword,char *line)
+
+{
+char *ptr;
+
+(void) strcpy(keyword,"");
+
+//removing head space
+while (line[0]==' ')
+ (void) memmove(line,line+1,strlen(line+1));
+//Extracting keyword
+(void) strcpy(keyword,line);
+if ((ptr=strchr(keyword,' '))!=(char *)0)
+ *ptr='\000';
+if ((ptr=strchr(keyword,'\n'))!=(char *)0)
+ *ptr='\000';
+
+//cleaning line
+ptr=line+strlen(keyword);
+(void) memmove(line,ptr,strlen(ptr));
+while (line[0]==' ')
+ (void) memmove(line,line+1,strlen(line+1));
+return strlen(keyword);
+}
+/*
+\f
+*/
+/********************************************************/
+/* */
+/* Procedure to check domain/peerip status */
+/* */
+/********************************************************/
+static int checkstatus(char *domain,char *peerip,char *spfstr)
+
+{
+_Bool status;
+int try;
+SPFENU spf;
+AFNTYP *afnnum;
+
+status=true;
+try=0;
+afnnum=afn_getipnum(peerip);
+spf=spf_getstatus(&try,domain,afnnum);
+if (strcmp(spfstr,spf_spfASCII(spf))!=0)
+ status=false;
+afnnum=afn_freeipnum(afnnum);
+return status;
+}
+/*
+\f
+*/
+/********************************************************/
+/* */
/* Procedure to scan a line from the test file */
/* */
/********************************************************/
-static int scanline(FILE *fichier)
+static int scanline(char *filename,FILE *fichier)
{
+#define MAX 300
+
int status;
int num;
-char line[300];
+char line[MAX];
+char domain[MAX];
+char peerip[MAX];
+char spfstr[MAX];
status=0;
num=0;
*ptr='\000';
if (strlen(line)==0)
continue;
- (void) rou_alert(0,"JMPDBG line='%d' <%s>",num,line);
+ //replacing HT by space
+ while ((ptr=strchr(line,'\t'))!=(char *)0)
+ *ptr=' ';
+ //removing head space
+ while (line[0]==' ')
+ (void) memmove(line,line+1,strlen(line+1));
+ (void) getkeyword(domain,line);
+ (void) getkeyword(peerip,line);
+ (void) getkeyword(spfstr,line);
+ if (checkstatus(domain,peerip,spfstr)==false) {
+ status=-1;
+ break;
+ }
+ }
+if (status!=0) {
+ (void) rou_alert(0,"SPF fail in file <%s> in line='%03d'",
+ filename,num);
+ (void) rou_alert(0,"\t for domain <%s> peerip=<%s>",
+ domain,peerip);
}
return status;
+
+#undef MAX
}
/*
\f
}
break;
case 1 : //scan the file
- (void) scanline(fichier);
+ (void) rou_alert(0,"scanning test file <%s>",rootname);
+ status=scanline(rootname,fichier);
+ if (status==0)
+ (void) rou_alert(0,"\t Test OK");
break;
case 2 : //scan the file
(void) fclose(fichier);
status=0;
for (int i=0;i<params->argc;i++) {
- (void) fprintf(stdout,"Doing test pattern <%s>\n",params->argv[i]);
(void) scantest(params->argv[i]);
}
return status;