/* server. */
/* */
/************************************************/
-static _Bool dosenddata(FEEDTYP *fd)
+static _Bool dosenddata(FEEDTYP *fd,int *numline)
{
#define OPEP "feeder.c:dosenddata,"
_Bool completed;
completed=true;
+ (*numline)++;
(void) eml_removecrlf(data);
switch (data[0]) {
case 'D' :
/* protocol. */
/* */
/********************************************************/
-static _Bool docommand(FEEDTYP *fd,int numline,char *line)
+static _Bool docommand(FEEDTYP *fd,int *numline,char *line)
{
+#define OPEP "docommand"
+
_Bool status;
char *param;
switch (getcmd(line)) {
case cmd_comment : //detect comment flag
if (setcomment(fd,param)==false)
- (void) report(numline,line,"Unable to set comment mode");
+ (void) report(*numline,line,"Unable to set comment mode");
break;
case cmd_data : //sending email content to remote
- if ((status=dosenddata(fd))==false)
- (void) report(numline,line,"Unable to fully send data");
+ if ((status=dosenddata(fd,numline))==false)
+ (void) report(*numline,line,"Unable to fully send data");
break;
case cmd_gotls : //GOTLS
if ((status=gomodetls(fd->socptr))==false)
- (void) report(numline,line,"Unable to set TLS mode");
+ (void) report(*numline,line,"Unable to set TLS mode");
break;
case cmd_orgn : //Changing PEERIP
if (param!=(char *)0) {
if(( status=dorestart(fd,param))==false)
- (void) report(numline,line,"Unable to change srcip!");
+ (void) report(*numline,line,"Unable to change srcip!");
}
else {
- (void) report(numline,line,"Missing new PEER IP value");
+ (void) report(*numline,line,"Missing new PEER IP value");
status=false;
}
break;
case cmd_restart : //restart link
if ((status=dorestart(fd,(char *)0))==false)
- (void) report(numline,line,"Unable to restart feed socket!");
+ (void) report(*numline,line,"Unable to restart feed socket!");
break;
case cmd_wait : //SLEEP mode
if (param!=(char *)0)
(void) sleep(atoi(param));
else {
- (void) report(numline,line,"Missing 'seconds' parameters");
+ (void) report(*numline,line,"Missing 'seconds' parameters");
status=false;
}
break;
case cmd_unknown :
default :
- (void) report(numline,line,"Unknown command");
+ (void) report(*numline,line,"Unknown command");
status=false;
break;
}
return status;
+#undef OPEP
}
/*
\f
/* Scanning one line from test file */
/* */
/********************************************************/
-static _Bool scanline(FEEDTYP *fd,int numline,char *line)
+static _Bool scanline(FEEDTYP *fd,int *numline,char *line)
{
#define OPEP "feeder.c:scanline"
case 0 : //removing first space
while ((line[0]==' ')||(line[0]=='\t'))
(void) memmove(line,line+1,(strlen(line+1)+1));
- if (line[0]=='#') //line is a comment.
- proceed=false;; //discarding line
+ if (line[0]=='#') { //line is a comment.
+ proceed=false;; //discarding line
+ (*numline)++;
+ }
break;
case 1 : //checking if test file format is OK
if (line[1]!=':') {
- (void) report(numline,line,"Malformed test data");
+ (void) report(*numline,line,"Malformed test data");
status=false;
proceed=false; //discarding line
}
status=docommand(fd,numline,line);
break;
case 'R' : //Receiving data
- status=doincoming(fd->socptr,numline,line);
+ status=doincoming(fd->socptr,*numline,line);
break;
case 'S' : //sending data
(void) dooutgoing(fd->socptr,line);
break;
default : //Unexpected
line-=2;
- (void) report(numline,line,"Unexpected directive");
+ (void) report(*numline,line,"Unexpected directive");
status=false;
break;
}
+ (*numline)++;
break;
default : //SAFE Guard
proceed=false;
status=false;
(void) strcpy(testname,"");
-numline=0;
+numline=1;
(void) strcpy(line,"");
phase=0;
proceed=true;
while (fgets(line,sizeof(line),fd->datatst)!=(char *)0) {
char *ptr;
- numline++;
+ (void) rou_alert(0,"%s num='%02d' <%s>","sender",numline,line);
while ((ptr=strrchr(line,'\n'))!=(char *)0)
*ptr='\000';
- if ((fd->commented==true)&&(strncmp(line,"C:",2)!=0))
- continue;
- if (scanline(fd,numline,line)==false) {
+ if ((fd->commented==true)&&(strncmp(line,"C:",2)!=0)) {
+ numline++;
+ continue;
+ }
+ if (scanline(fd,&numline,line)==false) {
phase=999; //Trouble trouble exiting
break;
}