From: Jean-Marc Pigeon (Delson) Date: Tue, 18 Mar 2025 13:33:46 +0000 (-0400) Subject: Adjusting gestcp to use socket reference X-Git-Tag: tag-0.7~72 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=f3d46a328277c677249de50a5a7337413afbf8ca;p=jmp%2Fmailleur Adjusting gestcp to use socket reference --- diff --git a/lib/gestcp.c b/lib/gestcp.c index 1ca136d..ce68f34 100644 --- a/lib/gestcp.c +++ b/lib/gestcp.c @@ -57,7 +57,7 @@ return contact; /* 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" @@ -72,17 +72,17 @@ proceed=true; 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)) @@ -93,7 +93,7 @@ while (proceed==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? } @@ -118,14 +118,14 @@ return got; /* 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; } /* diff --git a/lib/gestcp.h b/lib/gestcp.h index bd43d3f..30c1ab3 100644 --- a/lib/gestcp.h +++ b/lib/gestcp.h @@ -29,10 +29,10 @@ typedef struct { }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); diff --git a/lib/lvleml.c b/lib/lvleml.c index f264be7..5205cb9 100644 --- a/lib/lvleml.c +++ b/lib/lvleml.c @@ -33,8 +33,8 @@ va_start(args,fmt); 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); } @@ -271,7 +271,7 @@ while (proceed==true) { 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);