]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Adjusting gestcp to use socket reference
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Tue, 18 Mar 2025 13:33:46 +0000 (09:33 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Tue, 18 Mar 2025 13:33:46 +0000 (09:33 -0400)
lib/gestcp.c
lib/gestcp.h
lib/lvleml.c

index 1ca136d2546ba1da0f47c37a07e6ea4eae89fb22..ce68f3422b5d4065dc7be72822533ef5dd6f8d4f 100644 (file)
@@ -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;
 }
 /*
index bd43d3f2f631cc412065e4918c94037f82c3f474..30c1ab3f8e14085d20e618204d9496aa77146aa7 100644 (file)
@@ -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);
index f264be71b69f0422e613279344524b96954f329e..5205cb9e09d3613be62f6589194a72dbf72777aa 100644 (file)
@@ -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);