{
(void) soc_writebuffer(socptr,line,strlen(line));
(void) soc_writebuffer(socptr,"\r\n",2);
-(void) fprintf(stdout,"JMPDBG sending <%s>\n",line);
}
/*
\f
{
#define OPEP "tstfeed.c:doincoming"
+#define STRETC "..."
_Bool status;
char *received;
+int tocheck;
int phase;
_Bool proceed;
status=false;
received=(char *)0;
+tocheck=strlen(line);
phase=0;
proceed=true;
while (proceed==true) {
//(void) fprintf(stdout,"JMPDBG %s, phase='%d'\n",OPEP,phase);
switch (phase) {
- case 0 : //waiting for a line with CRLF
+ case 0 : //do we have a "..." sequence at the end
+ if (tocheck>0) {
+ char *ptr;
+
+ if ((ptr=strstr(line,STRETC))!=(char *)0) {
+ if (strlen(ptr)==strlen(STRETC)) {
+ tocheck-=strlen(STRETC);
+ }
+ }
+ }
+ break;
+ case 1 : //waiting for a line with CRLF
if (tcp_getline(socptr,WAITLINE,&received)==0) {
(void) fprintf(stdout,"Unable to receive line in due time\n");
phase=999; //No need to go further
}
break;
- case 1 : //get available character
- (void) fprintf(stdout,"Remote say <%s>\n",received);
+ case 2 : //get available character
+ if (strncmp(line,received,tocheck)!=0) {
+ (void) fprintf(stdout,"Line %04d: Error!\n",numline);
+ (void) fprintf(stdout,"expecting\t'%s'\n",line);
+ (void) fprintf(stdout,"found\t\t'%s'\n",received);
+ phase=999;
+ }
received=rou_freestr(received);
+ break;
+ case 3 : //everything fine
+ //(void) fprintf(stdout,"JMPDBG line <%s> OK!\n",line);
status=true;
break;
default : //SAFE Guard
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
break;
- case 1 : //discarding comment
+ case 1 : //checking if test file format is OK
+ if (line[1]!=':') {
+ (void) report(numline,line,"Malformed test data");
+ status=false;
+ proceed=false; //discarding line
+ }
+ break;
+ case 2 : //discarding comment
switch (line[0]) {
- case '#' : //line is comment
- break;
- case '<' : //incoming expected
- status=doincoming(socptr,numline,line);
+ case 'R' : //Receiving data
+ status=doincoming(socptr,numline,line+2);
break;
- case '>' : //incoming expected
- (void) dooutgoing(socptr,line+1);
+ case 'S' : //sending data
+ (void) dooutgoing(socptr,line+2);
break;
default : //Unexpected
- line[1]='\000';
- (void) report(numline,line,"unexpected directive");
+ (void) report(numline,line+2,"Bigre unexpected directive");
status=false;
break;
}