comparison src/server.c @ 482:a04c52f87b6e noffle

[svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c: Add new '-U, --uninteresting' option. This removes an article from the list of requested articles and removes its INTERESTING marker.
author bears
date Thu, 14 Oct 2004 00:26:48 +0100
parents 466b42bb776e
children a02417000b7b
comparison
equal deleted inserted replaced
481:0a5dc5f69746 482:a04c52f87b6e
1 /* 1 /*
2 server.c 2 server.c
3 3
4 $Id: server.c 566 2003-06-20 10:46:06Z bears $ 4 $Id: server.c 629 2004-10-13 23:26:48Z bears $
5 */ 5 */
6 6
7 #if HAVE_CONFIG_H 7 #if HAVE_CONFIG_H
8 #include <config.h> 8 #include <config.h>
9 #endif 9 #endif
415 loadGrpInfo( group ); 415 loadGrpInfo( group );
416 } 416 }
417 return TRUE; 417 return TRUE;
418 } 418 }
419 419
420 static void
421 findServer( const char *msgId, Str result )
422 {
423 const char *p, *pColon, *srv;
424 Str s, grp;
425
426 Utl_cpyStr( result, "(unknown)" );
427 if ( Db_contains( msgId ) )
428 {
429 Utl_cpyStr( s, Db_xref( msgId ) );
430 p = strtok( s, " \t" );
431 if ( p )
432 do
433 {
434 pColon = strstr( p, ":" );
435 if ( pColon )
436 {
437 Utl_cpyStrN( grp, p, pColon - p );
438 srv = Grp_server( grp );
439 if ( Cfg_servIsPreferential( srv, result ) )
440 Utl_cpyStr( result, srv );
441 }
442 }
443 while ( ( p = strtok( NULL, " \t" ) ) );
444 }
445 }
446
447 static Bool 420 static Bool
448 retrieveArt( const char *msgId ) 421 retrieveArt( const char *msgId )
449 { 422 {
450 Str s; 423 Str s;
451 int stat; 424 int stat;
452 425 Bool foundServer;
453 findServer( msgId, s ); 426
454 if ( strcmp( s, "(unknown)" ) == 0 427 foundServer = Db_findServer( msgId, s );
455 || strcmp( s, GRP_LOCAL_SERVER_NAME ) == 0 ) 428 if ( ! foundServer || strcmp( s, GRP_LOCAL_SERVER_NAME ) == 0 )
456 return FALSE; 429 return FALSE;
457 if ( ! Client_connect( s ) ) 430 if ( ! Client_connect( s ) )
458 { 431 {
459 Log_inf( "Connection to server failed. Leaving online mode." ); 432 Log_inf( "Connection to server failed. Leaving online mode." );
460 Online_set( FALSE ); 433 Online_set( FALSE );
580 static void 553 static void
581 doBodyInDb( const char *msgId ) 554 doBodyInDb( const char *msgId )
582 { 555 {
583 unsigned status; 556 unsigned status;
584 Str srv; 557 Str srv;
558 Bool foundServer;
585 559
586 status = Db_status( msgId ); 560 status = Db_status( msgId );
587 if ( status & DB_RETRIEVING_FAILED ) 561 if ( status & DB_RETRIEVING_FAILED )
588 { 562 {
589 Db_setStatus( msgId, status & ~DB_RETRIEVING_FAILED ); 563 Db_setStatus( msgId, status & ~DB_RETRIEVING_FAILED );
590 putTxtBuf( Db_body( msgId ) ); 564 putTxtBuf( Db_body( msgId ) );
591 } 565 }
592 else if ( status & DB_NOT_DOWNLOADED ) 566 else if ( status & DB_NOT_DOWNLOADED )
593 { 567 {
594 findServer( msgId, srv );
595 if ( Req_contains( srv, msgId ) ) 568 if ( Req_contains( srv, msgId ) )
569 {
596 putTxtBuf( Pseudo_alreadyMarkedBody() ); 570 putTxtBuf( Pseudo_alreadyMarkedBody() );
597 else if ( strcmp( srv, "(unknown)" ) != 0 && 571 }
598 strcmp( srv, GRP_LOCAL_SERVER_NAME ) != 0 && 572 else
599 Req_add( srv, msgId ) ) 573 {
600 putTxtBuf( Pseudo_markedBody() ); 574 foundServer = Db_findServer( msgId, srv );
601 else 575 if ( ! foundServer && strcmp( srv, GRP_LOCAL_SERVER_NAME ) != 0 )
602 putTxtBuf( Pseudo_markingFailedBody() ); 576 {
577 Log_err( "Can't find server for message %s", msgId );
578 putTxtBuf ( Pseudo_markingFailedBody() );
579 }
580 else if ( Req_add( srv, msgId ) )
581 putTxtBuf( Pseudo_markedBody() );
582 else
583 putTxtBuf( Pseudo_markingFailedBody() );
584 }
603 } 585 }
604 else 586 else
605 putTxtBuf( Db_body( msgId ) ); 587 putTxtBuf( Db_body( msgId ) );
606 } 588 }
607 589