RU.QICO------------------ < Пред. | След. > -- < @ > -- < Сообщ. > -- < Эхи > --
 Nп/п : 56 из 87
 От   : Sergey Anohin                       2:5034/10.1       01 фев 24 20:51:33
 К    : Nil A                                                 01 фев 24 20:59:01
 Тема : Сборка QICO
----------------------------------------------------------------------------------
                                                                                 
@MSGID: 2:5034/10.1 f95691df
@REPLY: 2:5015/46 65bbc7a3
@CHRS: CP866 2
@PID: wfido 0.0.1/a
@TID: FTN::Pkt 1.02
@Posted: 01 Feb 24 20:56:50
Hello, Nil!

  NA> Ты всегда можешь "нормализовать" код пропустив через
автоформатор, какой-нибудь clang-format. А после уже сравнивать версии, и должно
быть сильно меньше дифф.

Слушай, ну astyle с опцией -j -A1 или -A2 рулит:
Пара примеров:

# diff -Bburw ./qico/src/emsi.c ./trunk/src/emsi.c.new
--- ./qico/src/emsi.c   2024-02-01 20:42:42.452550000 +0300
+++ ./trunk/src/emsi.c.new      2024-02-01 20:41:44.545642000 +0300
@@ -2,7 +2,7 @@
  * EMSI management.
  **********************************************************/
 /*
- * $Id: emsi.c,v 1.24 2005/08/12 15:36:19 mitry Exp $
+ * $Id: emsi.c 48 2014-11-29 09:03:48Z semik $
  *
  * $Log: emsi.c,v $
  * Revision 1.24  2005/08/12 15:36:19  mitry
@@ -277,16 +277,16 @@
         return 0;
     }

-    sscanf( str + 10, "%04zX", &l );
+    sscanf( str + 10, "%04X", (unsigned *) &l );
     if ( l != ( l1 = strlen( str ) - 18 ))
     {
-        write_log( "Bad EMSI_DAT length: %zu, should be: %zu!", l, l1 );
+        write_log( "Bad EMSI_DAT length: %u, should be: %u!", l, l1 );
         return 0; /* Bad EMSI length */
     }

     DEBUG((`E`,5,"EMSI_DAT length (%d) is OK!", l ));

-    sscanf( str + strlen( str ) - 4, "%04zX", &l);
+    sscanf( str + strlen( str ) - 4, "%04X", &l);
     if ( l != ( l1 = crc16usd( (UINT8 *) str + 2, strlen( str ) - 6 )))
     {
         write_log( "Bad EMSI_DAT CRC: %04X, should be: %04X!", l, l1 );
@@ -649,8 +649,8 @@
     EMSI_CAT( "}" );

     /* Calculate emsi length */
-    snprintf( tmp, TMP_LEN, "%04zX", strlen( emsi_dat ) - 14 );
-    memcpy( emsi_dat + 10, tmp, 4 );
+    snprintf( tmp, TMP_LEN, "%04X", strlen( emsi_dat ) - 14 );
+    memmove( emsi_dat + 10, tmp, 4 );

     /* EMSI crc16 */
     snprintf( tmp, TMP_LEN, "%04X", crc16usds( (UINT8 *) emsi_dat + 2 ));
@@ -1096,7 +1096,7 @@
                     if ( rew && rew != emsi_dat )
                     {
                         DEBUG((`E`,1,"got EMSI_DAT at offset %d", p - rew));
-                        memcpy( emsi_dat, rew, p - rew );
+                        memmove( emsi_dat, rew, p - rew );
                         p -= rew - emsi_dat;
                     }
                     else

Но мне пришлось обе версии форматировать, это конечно плохо но не смертельно.
И вот в принципе бинк как ужался:

# diff -Bburw ./qico/src/binkp.c ./trunk/src/binkp.c
--- ./qico/src/binkp.c  2024-02-01 20:44:10.345036000 +0300
+++ ./trunk/src/binkp.c 2024-02-01 20:44:15.968797000 +0300
@@ -2,9 +2,27 @@
  * Binkp protocol implementation.
  ******************************************************************/
 /*
- * $Id: binkp.c,v 1.20 2005/08/22 17:19:41 mitry Exp $
+ * $Id: binkp.c 48 2014-11-29 09:03:48Z semik $
  *
  * $Log: binkp.c,v $
+ * Revision 1.26  2007/03/19 23:58:06  mitry
+ * *** empty log message ***
+ *
+ * Revision 1.25  2007/03/19 23:39:41  mitry
+ * ND mode should be implemented
+ *
+ * Revision 1.24  2006/07/10 16:16:29  mitry
+ * Binkp: prevent infinite calling system if some files were suspended
+ *
+ * Revision 1.23  2006/04/14 18:55:10  mitry
+ * Drop session if secure aka is busy.
+ *
+ * Revision 1.22  2005/12/03 02:44:19  mitry
+ * Fixed session timeout between two qicos
+ *
+ * Revision 1.21  2005/09/06 20:42:04  mitry
+ * Added macros to qpreset() calls
+ *
  * Revision 1.20  2005/08/22 17:19:41  mitry
  * Changed names of functions to more proper form
  *
@@ -149,7 +167,10 @@
             break;

         case `d`:                                      /* No dupes mode */
+            break;
+#if 0
             bps->opt_nd |= O_NO; /*mode?O_THEY:O_NO;*/
+#endif

         case `r`:                                      /* Non-reliable mode */
             bps->opt_nr |= to ? O_WANT : O_NO;
@@ -174,6 +195,7 @@
     }

     bps->MD_chal = NULL;
+    bps->was_suspend = 0;

     return OK;
 }
@@ -368,7 +390,7 @@

         ti = time( NULL );
         TZOFFSET = gmtoff( ti );
-        memcpy( &tt, localtime( &ti ), sizeof( struct tm ));
+        memmove( &tt, localtime( &ti ), sizeof( struct tm ));

 #define BMALTL ((size_t)((byte *) buf - (byte *) arg ) < len )

@@ -496,11 +518,7 @@
         {
             write_log("Binkp: got bad VER message: %s", buf );
         }
-        if ( BP_VER( bp ) <= 100 )
-        {
-            bp->delay_eob = 1;
         }
-    }
     else if ( !strncmp( buf, "TRF ", 4 ))
     {
         n = skip_blanks( buf + 4 );
@@ -513,11 +531,7 @@
                 rnode->files = atoi( n );
             }
         }
-        if ( rnode->netmail + rnode->files )
-        {
-            bp->delay_eob = 1;
         }
-    }
     else if( !strncmp( buf, "FREQ", 4 ))
     {
         bp->delay_eob = 1;
@@ -545,6 +559,7 @@
             {
                 bp->opt_mb |= O_WE;
             }
+#if 0
             else if( !strcmp( p, "ND" ))
             {
                 bp->opt_nd |= O_WE;
@@ -553,6 +568,7 @@
             {
                 bp->opt_nd |= O_EXT;
             }
+#endif
             else if( !strcmp( p, "CHAT" ))
             {
                 bp->opt_cht |= O_WE;
@@ -631,22 +647,22 @@
             /* Search for duplicated remote akas */
             if ( !falist_find( rnode->addrs, &fa ))
             {
-                if ( outbound_locknode( &fa, LCK_s ))
+                char           *rpwd = findpwd( &fa );
+                falist_t       *xfa;
+
+                xfa = falist_add( &rnode->addrs, &fa );
+                if ( outbound_locknode( &xfa->addr, LCK_s ))
                 {

                     DEBUG((`B`,4,"locked: %s", rem_aka));

-                    if ( !bp->to && !rem_pwd )
+                    if ( !bp->to && !rem_pwd && rpwd )
                     {
-                        rem_pwd = findpwd( &fa );
-                        if ( rem_pwd )
-                        {
+                        rem_pwd = rpwd;
  DEBUG((`B`,4,"found pwd `%s` for %s", rem_pwd, rem_aka));
                         }
-                    }

                     rc++;
-                    falist_add( &rnode->addrs, &fa );
                     makeflist( &fl, &fa, bp->to );

                     DEBUG((`B`,4,"totalm: %lu, totalf: %lu", totalm, totalf));
@@ -654,9 +670,17 @@
                 }
                 else
                 {
 - write_log( "Can`t lock outbound for %s", ftnaddrtoa( &fa ));
+                    write_log( "Can`t lock outbound for %saka %s",
+                               (rpwd ? "secure " : ""), ftnaddrtoa( &fa ));
+                    if ( rpwd )
+                    {
+                        log_rinfo( rnode );
+                        msgs( BPM_BSY, "Secure aka is busy" );
+                        bp->rc = ( bp->to ? S_REDIAL | S_ADDTRY : S_BUSY );
+                        return 0;
                     }
                 }
+            }
             else
             {
                 DEBUG((`B`,4,"removed duplicated aka: %s", rem_aka));
@@ -761,10 +785,6 @@
         bp->opt_nd = O_NO;
     }

-    if ( !rnode->phone || !*rnode->phone )
-    {
-        restrcpy( &rnode->phone, "-Unpublished-" );
-    }
     if ( !( rnode->options & O_PWD ) || bp->opt_md != O_YES )
     {
         bp->opt_cr = O_NO;
@@ -827,10 +847,7 @@
         bp->opt_mb = O_NO;
     }

-    if ( BP_VER( bp ) > 100 )
-    {
-        bp->delay_eob = 0;
-    }
+    bp->delay_eob = ( BP_VER( bp ) < 101 );

     snprintf( tmp, 255, "Binkp%s%s%s%s%s%s%s%s%s",
               ( rnode->options & O_LST ) ? "/LST" : "",
@@ -847,8 +864,8 @@

  title( "%sbound session %s", bp->to ? "Out" : "In", ftnaddrtoa(
&rnode->addrs->addr ));
     qemsisend( rnode );
-    qpreset( 0 );
-    qpreset( 1 );
+    qpreset( QPR_RECV );
+    qpreset( QPR_SEND );

     sendf.allf = totaln;
     sendf.ttot = totalf + totalm;
@@ -1061,7 +1078,7 @@
               ( bp->opt_nd & O_THEY ) ? " ND" : "",
               ( bp->opt_mb & O_WANT ) ? " MB" : "",
               ( bp->opt_cht & O_WANT ) ? " CHAT" : "",
 - (( !( bp->opt_nd & O_WE )) != ( !( bp->opt_nd & O_THEY ))) ?
" NDA": "",
 + /*(( !( bp->opt_nd & O_WE )) != ( !( bp->opt_nd & O_THEY ))) ?
" NDA":*/ "",
  (( bp->opt_cr & O_WE ) && ( bp->opt_cr & O_THEY )) ? " CRYPT"
: "" );
     if ( strlen( tmp ))
     {
@@ -1144,6 +1161,8 @@
         }
     }

+    qpreset( QPR_RECV );
+
  DEBUG((`B`,4,"cls=%d, sent_eob=%d, recv_eob=%d", bp->cls, bp->sent_eob,
bp->recv_eob));

     return 1;
@@ -1190,7 +1209,8 @@
 static int M_get(BPS *bp, byte *arg)
 {
     char       *buf = (char *) arg, *fname;
-    long       fsize, ftime, foffs;
+    long       fsize, foffs;
+    time_t     ftime;

     DEBUG((`B`,3,"GET %s", buf));

@@ -1237,7 +1257,8 @@
     char       *buf = (char *) arg;
     char       *fname;
     int        id = *bp->rx_buf;
-    long       fsize, ftime;
+    long       fsize;
+    time_t     ftime;

     DEBUG((`B`,3,"%s %s", mess[id], buf));

@@ -1246,15 +1267,18 @@
         if ( sendf.fname && !strncasecmp( fname, sendf.fname, MAX_PATH )
                 && sendf.mtime == ftime && sendf.ftot == fsize )
         {
+            int        is_skip = ( id == BPM_SKIP );
+
             if ( bp->send_file )
             {
                 DEBUG((`B`,1,"file %s %s",
                        sendf.fname,
-                       ( id == BPM_GOT ) ? "skipped" : "suspended"));
+                       is_skip ? "suspended" : "skipped"));

-                txclose( &txfd, ( id == BPM_GOT ) ? FOP_SKIP : FOP_SUSPEND );
-                bp->ticskip = ( id == BPM_GOT ) ? 1 : 2;
-                bp->oflist->suspend = ( id == BPM_SKIP );
+                txclose( &txfd, is_skip ? FOP_SUSPEND : FOP_SKIP );
+                bp->ticskip = is_skip + 1;
+                bp->oflist->suspend = is_skip;
+                bp->was_suspend += is_skip;
                 flexecute( bp->oflist );
                 bp->send_file = 0;
                 qpfsend();
@@ -1265,13 +1289,14 @@
             {
                 DEBUG((`B`,1,"file %s %s",
                        sendf.fname,
-                       ( id == BPM_GOT ) ? "done" : "suspended"));
+                       is_skip ? "suspended" : "done"));

                 bp->wait_got = 0;
-                txclose( &txfd, ( id == BPM_GOT ) ? FOP_OK : FOP_SUSPEND );
+                txclose( &txfd, is_skip ? FOP_SUSPEND : FOP_OK );

-                bp->ticskip = ( id == BPM_GOT ) ? 0 : 2;
-                bp->oflist->suspend = ( id == BPM_SKIP );
+                bp->ticskip = is_skip ? 2 : 0;
+                bp->oflist->suspend = is_skip;
+                bp->was_suspend += is_skip;
                 flexecute( bp->oflist );
                 qpfsend();
             }
@@ -1280,54 +1305,9 @@
                 write_log( "Binkp: got M_%s for unknown file", mess[id] );
             }
         }
-#if 0
 - if ( bp->send_file && sendf.fname && !strncasecmp( fname,
sendf.fname, MAX_PATH )
-                && sendf.mtime == ftime && sendf.ftot == fsize )
-        {
-
 - DEBUG((`B`,1,"file %s %s", sendf.fname, ( id == BPM_GOT ) ?
"skipped" : "suspended"));
-            txclose( &txfd, ( id == BPM_GOT ) ? FOP_SKIP : FOP_SUSPEND );
-            if ( id == BPM_GOT )
-            {
-                flexecute( bp->oflist );
-                bp->ticskip = 1;
             }
             else
             {
-                bp->ticskip = 2;
-            }
-            bp->send_file = 0;
-            qpfsend();
-            return 1;
-        }
-
 - if ( bp->wait_got && sendf.fname && !strncasecmp( fname,
sendf.fname, MAX_PATH )
-                && sendf.mtime == ftime && sendf.ftot == fsize )
-        {
-
 - DEBUG((`B`,1,"file %s %s", sendf.fname, ( id == BPM_GOT ) ?
"done" : "suspended"));
-            bp->wait_got = 0;
-            txclose( &txfd, ( id == BPM_GOT ) ? FOP_OK : FOP_SUSPEND );
-
-            if ( id == BPM_GOT )
-            {
-                flexecute( bp->oflist );
-                bp->ticskip = 0;
-            }
-            else
-            {
-                bp->ticskip = 2;
-            }
-            qpfsend();
-        }
-        else
-        {
-            write_log( "Binkp: got M_%s for unknown file", mess[id] );
-        }
-#endif
-    }
-    else
-    {
         DEBUG((`B`,1,"got unparsable fileinfo"));
     }
     return 1;
@@ -1389,7 +1369,7 @@
                         break;
                     }

-                    memcpy( (void *) (bp->tx_buf + bp->tx_left),
+                    memmove( (void *) (bp->tx_buf + bp->tx_left),
                              bp->mqueue[i].msg, bp->mqueue[i].len );
                     bp->tx_left += bp->mqueue[i].len;
                     xfree( bp->mqueue[i].msg );
@@ -1407,10 +1387,11 @@
         {
             int blksz = MIN( BP_BLKSIZE, sendf.ftot - bp->txpos );

 - if (( rc = fread( bp->tx_buf + BLK_HDR_SIZE, 1, blksz, txfd ))
< 0 )
 + if (( rc = fread( bp->tx_buf + BLK_HDR_SIZE, 1, blksz, txfd ))
< blksz )
             {
                 sline("Binkp: file read error at pos %lu", bp->txpos);
-                DEBUG((`B`,1,"Binkp: file read error at pos %lu", bp->txpos));
+                write_log( "file read error at pos %lu: read %i, expected %i",
+                           bp->txpos, rc, blksz );
                 txclose( &txfd, FOP_ERROR );
                 bp->send_file = 0;
             }
@@ -1480,7 +1461,8 @@
     DEBUG((`B`,4,"got: data %d",bp->rx_size));
  DEBUG((`B`,4,"data: rxpos %lu, recvf.foff %lu", (long) bp->rxpos,
(long) recvf.foff ));

 - snprintf( tmp, 511, "%s %lu %lu", bp->rfname, (long) recvf.ftot,
bp->rmtime );
+    snprintf( tmp, 511, "%s %lu %lu", bp->rfname, (long) recvf.ftot,
+              (long unsigned) bp->rmtime );

     if ( rxstatus )
     {
@@ -1490,7 +1472,7 @@
         return 1;
     }

-    if (( n = fwrite( bp->rx_buf, 1, bp->rx_size, rxfd )) < 0 )
+    if (( n = fwrite( bp->rx_buf, 1, bp->rx_size, rxfd )) < bp->rx_size )
     {
         bp->recv_file = 0;
         sline( "Binkp: file write error" );
@@ -1727,7 +1709,7 @@

     if ( bp->to )
     {
-        msgs( BPM_NUL, "OPT NDA%s%s%s%s%s",
+        msgs( BPM_NUL, "OPT %s%s%s%s%s",
               ( bp->opt_nr  & O_WANT ) ? " NR"    : "",
               ( bp->opt_nd  & O_THEY ) ? " ND"    : "",
               ( bp->opt_mb  & O_WANT ) ? " MB"    : "",
@@ -1779,11 +1761,12 @@
     }

     bps->remaddr = remaddr;
-    xfree( rnode->phone );
+    restrcpy( &rnode->phone, "-Unpublished-" );

     rxstatus = 0;
     totaln = totalf = totalm = 0;
     got_req = 0;
+    emsi_lo = ( is_freq_available() == FR_NOTHANDLED ) ? O_NOFREQS : 0;
     receive_callback = receivecb;

     write_log( "starting %sbound Binkp session", mode ? "out" : "in" );
@@ -1857,6 +1840,7 @@
         {
             msgs( BPM_EOB, NULL );
             bps->sent_eob = 1;
+            qpreset( QPR_SEND );
         }

         bps->rc = S_OK;
@@ -1864,11 +1848,12 @@
         if ( bps->sent_eob && bps->recv_eob )
         {
             DEBUG((`B`,4,"mib=%d", bps->mib));
-            if ( bps->mib < 3 || BP_VER( bps ) <= 100 )
+            if ( bps->mib < 3 || BP_VER( bps ) < 101 )
             {
                 break;
             }
             bps->mib = bps->sent_eob = bps->recv_eob = 0;
+            continue;
         }

  wd = ( bps->nmsgs || bps->tx_left || ( bps->send_file && txfd &&
!bps->wait_for_get));
@@ -1911,6 +1896,11 @@
     {
  DEBUG((`S`,3,"Binkp chat autoclosed (%s)", timer_expired(chattimer) ?
"timeout" : "hangup" ));
         msgs( BPM_EOB, NULL );
+    }
+
+    if ( bps->to && bps->was_suspend )
+    {
+        bps->rc |= ( S_REDIAL | S_ADDTRY );
     }

     rc = bps->rc;


 Но мне такое нереально смержить, тут ведь надо понимать какие куски
взять откуда. Так что только если тебе ревьюировать :-)


С наилучшими пожеланиями, Sergey Anohin.

--- wfido
 * Origin: https://5034.ru/wfido (2:5034/10.1)
SEEN-BY: 50/8 109 606 240/1120 301/1 341/66 455/19
463/68 467/888 469/122
SEEN-BY: 4500/1 5001/100 5005/49 5010/352 5015/42
46 5020/113 290 545 715 830
SEEN-BY: 5020/846 848 1042 4441 9696 12000
5022/128 5023/24 5030/49 115 1081
SEEN-BY: 5030/1900 5034/10 13 5036/26 5053/51 58
5054/8 5058/104 5061/133
SEEN-BY: 5075/128 5083/1 444
@PATH: 5034/10 13 5020/715 1042 4441



   GoldED+ VK   │                                                 │   09:55:30    
                                                                                
В этой области больше нет сообщений.

Остаться здесь
Перейти к списку сообщений
Перейти к списку эх