home bbs files messages ]

Just a sample of the Echomail archive

Cooperative anarchy at its finest, still active today. Darkrealms is the Zone 1 Hub.

   JAMNNTPD      Support for the JAMNNTPD software client      2,630 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 1,410 of 2,630   
   Anton Shepelev [Guest] to mark lewis   
   Response to the LIST command   
   11 Jul 16 00:18:26   
   
   Mark Lewis:   
   AS>> Tommi's  instance  works  correctly  now, and I   
   AS>> hope yours does as well.   
   ML>   
   ML> i hope so, too :)   
   ML>   
   ML> news://news.wpusa.dynip.com   
      
   Confirmed.   
      
   ML>>> if(matchgroup(var->postgroups,g-group))   
   ML>>> -   sockprintf(var,"%s %lu %lu y" CRLF,g->tagname,min,max);   
   ML>>> +   sockprintf(var,"%s %lu %lu y" CRLF,g->tagname,max,min);   
   ML>>> else   
   ML>>> -   sockprintf(var,"%s %lu %lu n" CRLF,g->tagname,min,max);   
   ML>>> +   sockprintf(var,"%s %lu %lu n" CRLF,g->tagname,max,min);   
   AS>> May I make so bold as to ask why you have these   
   AS>> almost identical lines of code   
   ML> because  they are what was there... the one with   
   ML> the '-' is the old removed line and the one with   
   ML> the  '+' is the new fixed line... i did it kinda   
   ML> like a diff but manually...   
      
   I know about the diff format and, not having used it   
   in a coon's lifetime, thought it was authentic diff!   
      
   AS>> instad of:   
   AS>> matchFlag = matchgroup(var->postgroups,g-group)) ? 'y' : 'n';   
   AS>> sockprintf(var,"%s %lu %lu %c" CRLF,g->tagname,max,min,matchFlag);   
   ML> because  that's not the way it is written in the   
   ML> JAMNNTPD v1.2 code, i guess... is that faster or   
   ML> otherwise  "better" in some way? i like the cur-   
   ML> rent way (above) for its  readability...  it  is   
   ML> easy  to  understand  what is being done... this   
   ML> new way, maybe not so easy to  read  and  under-   
   ML> stand...   
      
   When  offering  my  revision, I had in mind the OAOO   
   principle postulating that any  idea  shall  be  ex-   
   pressed in code once and only once:   
      
             http://c2.com/cgi/wiki?OnceAndOnlyOnce   
   See also: http://c2.com/cgi/wiki?search=onceandonlyonce   
      
   In my version the task of outputting a newsgroup en-   
   try is impleted in a single code  fragment,  so  one   
   shall not have to correct a single mistake twice, as   
   you have had.  I don't think it is less readable and   
   find  it even easier on the reader because he is not   
   forced to read duplicating code:  these  two  printf   
   lines differeing in but one character.   
      
   ML> besides,  i'm  just  working with what i have...   
   ML> i'm not even a C coder at all... i  much  prefer   
   ML> pascal,  asm,  perl,  bash,  4DOS scripting, and   
   ML> others ;)   
      
   Understood.  I myself have written nary a line in  C   
   since  university  and  prefer  Pascal, too (*shakes   
   hadnds*).   
      
   ML> FWIW: there's two typos, too...   
   ML> s/g-group/g->group/  and s/))/)/   
      
   Indeed.  My inattention.   
      
   ML> what type would matchFlag be? char, uchar, some-   
   ML> thing else? i see a lot of uchar definitions...   
      
   I  was  concise  because I wanted to demonstrate the   
   pith of my idea without writing a  lot  of  untested   
   code.  Whereas the flag is only used in the printf()   
   function it should make no difference whether it  be   
   signed  or  not,  and it doesn't in the quick test I   
   just made with gcc here on my 2007 MacBook.   
      
   ML> i finally settled on the following  code  purely   
   ML> from  guesswork and checking/fixing EMX compiler   
   ML> errors ;)   
   ML>   
   ML> void command_list(struct var *var)   
   ML> {  struct group *g;   
   ML>    ulong min,max,num;   
   ML>    uchar *arg;   
   ML>    uchar matchFlag;   
   ML>    bool listnewsgroups;   
   ML>    [...]   
   ML>    for(g=var->firstgroup;g && !var->disconnect && !get_serve   
   _quit();g=g->next)   
   ML>    {   
   ML>       if(matchgroup(var->readgroups,g->group))   
   ML>       {   
   ML>          if(listnewsgroups)   
   ML>          {   
   ML>             sockprintf(var,"%s  " CRLF,g->tagname);   
   ML>          }   
   ML>          else   
   ML>          {   
   ML>             if(!jamgetminmaxnum(var,g,&min,&max,&num))   
   ML>             {   
   ML>                min=0;   
   ML>                max=0;   
   ML>                num=0;   
   ML>             }   
   ML>   
   ML>             matchFlag = matchgroup(var->postgroups,g->group) ? 'y' : 'n';   
   ML>             sockprintf(var,"%s %lu %lu %c" CRLF,g->tagname,m   
   x,min,matchFlag);   
   ML>          }   
   ML>       }   
   ML>    }   
   ML>    socksendtext(var,"." CRLF);   
   ML> }   
      
   Here's my version, with comments:   
      
   void command_list( struct var *var )   
   {  struct group *g;   
      ulong min,max,num;   
      uchar *arg;   
      uchar matchFlag;   
      bool listnewsgroups;   
      [...]   
      for( g = var->firstgroup; g != NULL; g = g->next )   
      {  if( var->disconnect || get_server_quit() )   
         {  break;  } // separate exceptional conditions from list exhaustion   
         if( !matchgroup( var->readgroups, g->group ) )   
         {  continue;  } // coninue reduces the nesting of if statements   
         if( listnewsgroups )   
         {  sockprintf( var, "%s " CRLF, g->tagname );  }   
         else // TODO: if min, max, and num go together, wrap them into struct   
         {  if( !jamgetminmaxnum( var, g, &min, &max, &num) )   
            {  min = 0; max = 0; num = 0;  }   
            matchFlag = matchgroup( var->postgroups, g->group ) ? 'y' : 'n';   
            sockprintf( var, "%s %lu %lu %c" CRLF, g->tagname, max, min,   
   matchFlag );   
         }   
      }   
      // Strange: this will be called even after disconnect or server_quit:   
      socksendtext(var,"." CRLF);   
   }   
      
   ---   
    * Origin: *** nntp://fidonews.mine.nu *** Finland *** (2:221/6.0)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca