/* for a CRLF AS EOL. */
/* */
/********************************************************/
-PUBLIC int tcp_getline(CONTYP *contact,TIMESPEC *attend,char **lineptr)
+PUBLIC int tcp_getline(SOCPTR *socptr,TIMESPEC *attend,char **lineptr)
{
#define OPEP "gestcp.c:tcp_getline"
while (proceed==true) {
switch (phase) {
case 0 :
- if (contact==(CONTYP *)0) {
+ if (socptr==(SOCPTR *)0) {
(void) rou_alert(0,"%s socket pointer is NULL (Bug!?)",OPEP);
phase=999; //trouble trouble
}
break;
case 1 : //get nextline
- if ((got=soc_getnextline(contact->socptr,lineptr))>0)
+ if ((got=soc_getnextline(socptr,lineptr))>0)
phase=999; //we got a line.
break;
case 2 : //waiting for new character presence
- got=soc_waitforchar(contact->socptr,attend);
+ got=soc_waitforchar(socptr,attend);
switch (got) {
case -1 : //trouble? signal?
if ((hangup==true)||(reload==true))
break; //no need to read line
default : //char available
phase=0; //check for new line
- if (soc_receive(contact->socptr)<0) {
+ if (soc_receive(socptr)<0) {
got=-1;
phase=999; //remote disconnected?
}
/* return the number of char sent on channel. */
/* */
/********************************************************/
-PUBLIC int tcp_write(CONTYP *contact,char *buffer,int tosend)
+PUBLIC int tcp_write(SOCPTR *socptr,char *buffer,int tosend)
{
int sent;
sent=-1;
-if (contact!=(CONTYP *)0)
- sent=soc_writebuffer(contact->socptr,buffer,tosend);
+if (socptr!=(SOCPTR *)0)
+ sent=soc_writebuffer(socptr,buffer,tosend);
return sent;
}
/*
}CONTYP;
//read a line from contact up to CRLF
-extern int tcp_getline(CONTYP *contact,TIMESPEC *attend,char **lineptr);
+extern int tcp_getline(SOCPTR *socptr,TIMESPEC *attend,char **lineptr);
//Transmit formated data to the contact channel
-extern int tcp_write(CONTYP *contact,char *buffer,int tosend);
+extern int tcp_write(SOCPTR *socptr,char *buffer,int tosend);
//wait for an incoming contact
extern CONTYP *tcp_getcontact(SOCPTR *socptr,int pos);
line=(char *)0;
if (rou_vasprintf(&line,fmt,args)>0) {
(void) log_fprintlog(contact->logptr,true,"%s",line);
- (void) tcp_write(contact,line,strlen(line));
- (void) tcp_write(contact,CRLF,strlen(CRLF));
+ (void) tcp_write(contact->socptr,line,strlen(line));
+ (void) tcp_write(contact->socptr,CRLF,strlen(CRLF));
}
va_end(args);
}
attend.tv_sec=60;
attend.tv_nsec=0;
- status=tcp_getline(contact,&attend,&line);
+ status=tcp_getline(contact->socptr,&attend,&line);
if (status<=0) //timeout or trouble?
break; //no need to go further
(void) log_fprintlog(contact->logptr,false,"%s",line);