*/
/********************************************************/
/* */
+/* Procedure to execute a command to test SMTP */
+/* protocol. */
+/* */
+/********************************************************/
+static int getcmd(const char *command)
+
+
+{
+static struct {
+ int code;
+ const char *cmd;
+ }cmdavail[]={
+ {1,"GOTLS"},
+ {2,"SLEEP"},
+ {0,(const char *)0}
+ };
+
+int code;
+
+code=0;
+for (int i=0;cmdavail[i].cmd!=(const char *)0;i++) {
+ if (strcasecmp(cmdavail[i].cmd,command)==0) {
+ code=cmdavail[i].code;
+ break; //Code found
+ }
+ }
+return code;
+}
+/*
+\f
+*/
+/********************************************************/
+/* */
+/* Procedure to execute a command to test SMTP */
+/* protocol. */
+/* */
+/********************************************************/
+static _Bool docommand(SOCPTR *socptr,int numline,char *line)
+
+{
+_Bool status;
+char *param;
+
+status=false;
+if ((param=strchr(line,' '))!=(char *)0) {
+ *param='\000'; //cut line
+ param++; //pointer on parameter
+ }
+switch (getcmd(line)) {
+ case 1 : //GOTLS
+ (void) rou_alert(0,"JMPDBG got GOTTLS");
+ status=true;
+ break;
+ case 2 : //GOTLS
+ if (param==(char *)0)
+ (void) report(numline,line,"Missing 'seconds' parameters");
+ else {
+ (void) sleep(atoi(param));
+ status=true;
+ }
+ break;
+ default :
+ (void) report(numline,line,"Unknown command");
+ break;
+ }
+return status;
+}
+/*
+\f
+*/
+/********************************************************/
+/* */
/* Procedure to compare incoming data with expected*/
/* */
/********************************************************/
break;
case 2 : //discarding comment
switch (line[0]) {
- case 'T' : //Get the test titre
- status=strncpy(testname,line+2,sizeof(testname));
+ case 'C' : //command to execute
+ status=docommand(socptr,numline,line+2);
break;
case 'R' : //Receiving data
status=doincoming(socptr,numline,line+2);
case 'S' : //sending data
(void) dooutgoing(socptr,line+2);
break;
+ case 'T' : //Get the test titre
+ status=strncpy(testname,line+2,sizeof(testname));
+ break;
default : //Unexpected
- (void) report(numline,line+2,"Bigre unexpected directive");
+ (void) report(numline,line+2,"Unexpected directive");
status=false;
break;
}