phase=999; //Unable to send STARTTLS sequence
break;
case 1 : //Get STARTTLS command status
- if (tcp_getline(fd->socptr,WRESP,&line)<=0)
+ if (tcp_getline(fd->socptr,WRESP,&line)<0)
phase=999; //Didn't get signon
break;
case 2 : //did we received the Proper "proceed" acknoledge
case 3 : //
while (fgets(data,sizeof(data),fd->datatst)!=(char *)0) {
(void) eml_removecrlf(data);
- (void) rou_alert(0,"JMPDBG got <%s>",data);
(void) dooutgoing(fd->socptr,data);
- (void) rou_alert(0,"JMPDBG sent <%s>",data);
if ((empty==true)&&(strcmp(data,".")==0)) {
phase++; //Eveything is fine
break;
}
phase++;
}
+if (status==true)
+ (void) rou_alert(0,"Scanning file <%s> complted OK",filename);
return status;
}
/********************************************************/
*/
/********************************************************/
/* */
+/* Procedure to extract next line from the socket */
+/* incoming pile. */
+/* Return the number of character, zero if the */
+/* line is empty, -1 if now char available. */
+/* */
+/********************************************************/
+static int doextract(SOCTYP *soc,char **lineptr)
+
+{
+#define OPEP "devsoc.c:doextract,"
+
+int got;
+char *eol;
+int phase;
+_Bool proceed;
+
+*lineptr=(char *)0;
+got=-1;
+eol=(char *)0;
+phase=0;
+proceed=true;
+while (proceed==true) {
+ //(void) rou_alert(0,"JMPDBG %s phase='%d'",OPEP,phase);
+ switch (phase) {
+ case 0 : //Do we have dat in carpile
+ if (soc->carin==0)
+ phase=999; //No char,no need to check for line
+ break;
+ case 1 : //Do we have a CRLF
+ eol=strstr(soc->carpile,soc->EOL);
+ if (eol==(char *)0)
+ phase=999; //No End Of Line yet
+ break;
+ case 2 : //duplicating carpile
+ *lineptr=calloc(soc->carin+1,sizeof(char));
+ *eol='\000';
+ (void) strcpy(*lineptr,soc->carpile);
+ got=strlen(*lineptr);
+ break;
+ case 3 : //managing carpile
+ soc->carin-=(got+strlen(soc->EOL));
+ if (soc->carin>0) {
+ int delta;
+
+ delta=got+strlen(soc->EOL);
+ (void) memmove(soc->carpile,soc->carpile+delta,soc->carin);
+ }
+ soc->carpile[soc->carin]='\000';
+ break;
+ default : //SAFE guard
+ proceed=false;
+ break;
+ }
+ phase++;
+ }
+return got;
+#undef OPEP
+}
+/*
+\f
+*/
+/********************************************************/
+/* */
/* Procedure to wait and get a new handle */
/* */
/********************************************************/
/* */
/* Procedure to return the next available line */
/* within the socket carpile. */
+/* return the number of char within line */
+/* Return 0 if line is 'empty' */
+/* Return -1 if no characater available */
/* */
/********************************************************/
PUBLIC int soc_getnextline(SOCPTR *socptr,char **lineptr)
int got;
register SOCTYP *soc;
-char *eol;
int phase;
_Bool proceed;
*lineptr=(char *)0;
-got=0;
-eol=(char *)0;
+got=-1;
soc=(SOCTYP *)socptr;
phase=0;
proceed=true;
while (proceed==true) {
+ //(void) rou_alert(0,"JMPDBG %s phase='%d'",OPEP,phase);
switch (phase) {
case 0 : //Do we have dat in carpile
if (soc==(SOCTYP *)0) {
(void) rou_alert(0,"%s, socket binding reference is NULL (Bug!?)",OPEP);
phase=999; //no need to go further
}
- case 1 : //Do we have char available in carpile
- (void) soc_receive(socptr);
- if (soc->carin==0)
- phase=999; //No char,no need to check for line
- break;
- case 2 : //Do we have a CRLF
- eol=strstr(soc->carpile,soc->EOL);
- if (eol==(char *)0)
- phase=999; //No End Of Line yet
break;
- case 3 : //duplicating carpile
- *lineptr=calloc(soc->carin+1,sizeof(char));
- *eol='\000';
- (void) strcpy(*lineptr,soc->carpile);
- got=strlen(*lineptr);
+ case 1 : //Do we have char available in carpile
+ got=doextract(soc,lineptr);
+ if (got>=0) //we have line
+ phase=999; //no need to go further
break;
- case 4 : //managing carpile
- soc->carin-=(got+strlen(soc->EOL));
- if (soc->carin>0) {
- int delta;
-
- delta=got+strlen(soc->EOL);
- (void) memmove(soc->carpile,soc->carpile+delta,soc->carin);
- }
- soc->carpile[soc->carin]='\000';
+ case 2 : //lets wait for char
+ if (soc_receive(socptr)>0) //we have char
+ phase=0; //Let try to read line
break;
default : //SAFE guard
proceed=false;
phase=0;
proceed=true;
while (proceed==true) {
- (void) rou_alert(0,"JMPDBG %s phase='%d' empty='%d'",OPEP,phase,empty);
+ //(void) rou_alert(0,"JMPDBG %s phase='%d' empty='%d'",OPEP,phase,empty);
switch (phase) {
case 0 : //Do we have a parameter
(void) transmit(contact,"%d 3.5.0 %s",
}
break;
case 2 : //just display line
- (void) rou_alert(0,"%s, data=<%s>",OPEP,line);
if ((empty==false)||(strcmp(line,".")!=0))
phase=0; //Wait for next line
empty=false;
line=rou_freestr(line);
break;
case 3 : //got all data
- (void) rou_alert(0,"JMPDBG transmit OK");
(void) transmit(contact,"%d 3.5.3 %s",
CMDOK,"Message accepted for delivery");
+ done=true;
break;
default : //SAFE guard
proceed=false;